34 void*
memmem(
const void* l,
size_t l_len,
const void* s,
size_t s_len)
36 const register char *cur, *last;
37 const char* cl = (
const char*)l;
38 const char* cs = (
const char*)s;
41 if(l_len == 0 || s_len == 0)
55 return memchr(l, (
int)*cs, l_len);
59 last = cl + l_len - s_len;
61 for(cur = cl; cur <= last; cur++)
63 if(cur[0] == cs[0] &&
memcmp(cur, cs, s_len) == 0)
65 return (
void*)(uintptr_t)cur;
void * memmem(const void *l, size_t l_len, const void *s, size_t s_len)
Find substring s in memory area l.
int memcmp(const void *s1, const void *s2, size_t n)
Compares the first n characters of the two objects pointed to by s1 and s2.
void * memchr(const void *s, int c, size_t n)
Finds the first occurrence of c in the initial n characters of the object pointed to by s.