summaryrefslogtreecommitdiff
path: root/xs.h
diff options
context:
space:
mode:
Diffstat (limited to 'xs.h')
-rw-r--r--xs.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/xs.h b/xs.h
index 63342db..3758c8d 100644
--- a/xs.h
+++ b/xs.h
@@ -90,6 +90,7 @@ d_char *xs_number_new(double f);
90double xs_number_get(const char *v); 90double xs_number_get(const char *v);
91const char *xs_number_str(const char *v); 91const char *xs_number_str(const char *v);
92 92
93void *xs_memmem(const char *haystack, int h_size, const char *needle, int n_size);
93 94
94#ifdef XS_IMPLEMENTATION 95#ifdef XS_IMPLEMENTATION
95 96
@@ -907,6 +908,23 @@ const char *xs_number_str(const char *v)
907} 908}
908 909
909 910
911void *xs_memmem(const char *haystack, int h_size, const char *needle, int n_size)
912/* clone of memmem */
913{
914 char *p, *r = NULL;
915 int offset = 0;
916
917 while (!r && h_size - offset > n_size && (p = strchr(haystack + offset, *needle))) {
918 if (memcmp(p, needle, n_size) == 0)
919 r = p;
920 else
921 offset = p - haystack + 1;
922 }
923
924 return r;
925}
926
927
910#endif /* XS_IMPLEMENTATION */ 928#endif /* XS_IMPLEMENTATION */
911 929
912#endif /* _XS_H */ 930#endif /* _XS_H */