summaryrefslogtreecommitdiff
path: root/cogl
diff options
context:
space:
mode:
Diffstat (limited to 'cogl')
-rw-r--r--cogl/cogl-util.c24
-rw-r--r--cogl/cogl-util.h10
2 files changed, 34 insertions, 0 deletions
diff --git a/cogl/cogl-util.c b/cogl/cogl-util.c
index e8ffb04e..9ecc34c2 100644
--- a/cogl/cogl-util.c
+++ b/cogl/cogl-util.c
@@ -25,6 +25,8 @@
#include "config.h"
#endif
+#include <string.h>
+
#include "cogl-util.h"
#include "cogl-private.h"
@@ -252,4 +254,26 @@ _cogl_util_pixel_format_from_masks (unsigned long r_mask,
return image_format;
}
+#ifndef HAVE_MEMMEM
+
+char *
+_cogl_util_memmem (const void *haystack,
+ size_t haystack_len,
+ const void *needle,
+ size_t needle_len)
+{
+ size_t i;
+
+ if (needle_len > haystack_len)
+ return NULL;
+
+ for (i = 0; i <= haystack_len - needle_len; i++)
+ if (!memcmp ((const char *) haystack + i, needle, needle_len))
+ return (char *) haystack + i;
+
+ return NULL;
+}
+
+#endif /* HAVE_MEMMEM */
+
#endif /* _COGL_IN_TEST_BITMASK */
diff --git a/cogl/cogl-util.h b/cogl/cogl-util.h
index 67861bc5..4fb42274 100644
--- a/cogl/cogl-util.h
+++ b/cogl/cogl-util.h
@@ -268,4 +268,14 @@ _cogl_util_pixel_format_from_masks (unsigned long r_mask,
#define _Static_assert(EXPRESSION, MESSAGE)
#endif
+#ifdef HAVE_MEMMEM
+#define _cogl_util_memmem memmem
+#else
+char *
+_cogl_util_memmem (const void *haystack,
+ size_t haystack_len,
+ const void *needle,
+ size_t needle_len);
+#endif
+
#endif /* __COGL_UTIL_H */