4 * Find a byte string inside a longer byte string
6 * This uses the "Not So Naive" algorithm, a very simple but
7 * usually effective algorithm, see:
9 * http://www-igm.univ-mlv.fr/~lecroq/string/
14 void *memmem(const void *haystack, size_t n, const void *needle, size_t m)
16 const unsigned char *y = (const unsigned char *)haystack;
17 const unsigned char *x = (const unsigned char *)needle;
21 if (m > n || !m || !n)
35 if (x[1] != y[j + 1]) {
38 if (!memcmp(x + 2, y + j + 2, m - 2)