2 * Copyright (C) 2002 Manuel Novoa III
3 * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
5 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
11 void *memmem(const void *haystack
, size_t haystacklen
,
12 const void *needle
, size_t needlelen
)
14 register const char *ph
;
15 register const char *pn
;
20 return (void *) haystack
;
23 if (haystacklen
>= needlelen
) {
24 ph
= (const char *) haystack
;
25 pn
= (const char *) needle
;
26 plast
= ph
+ (haystacklen
- needlelen
);
30 while (ph
[n
] == pn
[n
]) {
31 if (++n
== needlelen
) {
35 } while (++ph
<= plast
);