about summary refs log tree commit diff
path: root/lib/util
diff options
context:
space:
mode:
Diffstat (limited to 'lib/util')
-rw-r--r--lib/util/nstring.c11
-rw-r--r--lib/util/nstring.h14
2 files changed, 18 insertions, 7 deletions
diff --git a/lib/util/nstring.c b/lib/util/nstring.c
index 1aec2b9d..feb8215e 100644
--- a/lib/util/nstring.c
+++ b/lib/util/nstring.c
@@ -878,16 +878,19 @@ stripeq(const char * const comparand,
 
 
 
-const char *
-memmemN(const char * const haystack,
+const void *
+memmemN(const void * const haystackArg,
         size_t       const haystacklen,
-        const char * const needle,
+        const void * const needleArg,
         size_t       const needlelen) {
 
+    const unsigned char * const haystack = haystackArg;
+    const unsigned char * const needle   = needleArg;
+
     /* This does the same as the function of the same name in the GNU
        C library
     */
-    const char * p;
+    const unsigned char * p;
 
     for (p = haystack; p <= haystack + haystacklen - needlelen; ++p)
         if (memeq(p, needle, needlelen))
diff --git a/lib/util/nstring.h b/lib/util/nstring.h
index f49c9927..de53fdac 100644
--- a/lib/util/nstring.h
+++ b/lib/util/nstring.h
@@ -47,6 +47,14 @@ strneq(const char * const comparand,
     return strncmp(comparand, comparator, size) == 0;
 }
 
+static __inline__ int
+memeq(const void * const comparand,
+      const void * const comparator,
+      size_t       const size) {
+    
+    return memcmp(comparand, comparator, size) == 0;
+}
+
 /* The Standard C Library may not declare strcasecmp() if the including
    source file doesn't request BSD functions, with _BSD_SOURCE.  So
    we don't define functions that use strcasecmp() in that case.
@@ -166,10 +174,10 @@ int
 stripeq(const char * const comparand,
         const char * const comparator);
 
-const char *
-memmemN(const char * const haystack,
+const void *
+memmemN(const void * const haystackArg,
         size_t       const haystacklen,
-        const char * const needle,
+        const void * const needleArg,
         size_t       const needlelen);
 
 bool