1 #include "../git-compat-util.h"
3 void *gitmemmem(const void *haystack, size_t haystack_len,
4 const void *needle, size_t needle_len)
6 const char *begin = haystack;
7 const char *last_possible = begin + haystack_len - needle_len;
10 * The first occurrence of the empty string is deemed to occur at
11 * the beginning of the string.
17 * Sanity check, otherwise the loop might search through the whole
20 if (haystack_len < needle_len)
23 for (; begin <= last_possible; begin++) {
24 if (!memcmp(begin, needle, needle_len))