[vala] glib-2.0: Do not use strnlen
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] glib-2.0: Do not use strnlen
- Date: Wed, 16 Mar 2011 17:35:40 +0000 (UTC)
commit 4305b796871402b0444c52204350f65ddd0dabdc
Author: Jürg Billeter <j bitron ch>
Date: Wed Mar 16 18:33:58 2011 +0100
glib-2.0: Do not use strnlen
strnlen is not available on all systems.
Fixes bug 644550.
vapi/glib-2.0.vapi | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/vapi/glib-2.0.vapi b/vapi/glib-2.0.vapi
index c9d7820..b953e68 100644
--- a/vapi/glib-2.0.vapi
+++ b/vapi/glib-2.0.vapi
@@ -1277,8 +1277,19 @@ public class string {
[CCode (cname = "g_strndup")]
public string ndup (size_t n);
- [CCode (cname = "strnlen")]
- static long strnlen (char* str, size_t maxlen);
+ [CCode (cname = "memchr")]
+ static char* memchr (char* s, int c, size_t n);
+
+ // strnlen is not available on all systems
+ static long strnlen (char* str, long maxlen) {
+ char* end = memchr (str, 0, maxlen);
+ if (end == null) {
+ return maxlen;
+ } else {
+ return (long) (end - str);
+ }
+ }
+
[CCode (cname = "g_strndup")]
static string strndup (char* str, size_t n);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]