Fix handling of one case, should be a good memmem() now.
git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@517 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
parent
4e8ab56781
commit
87fbce804c
|
@ -8,18 +8,25 @@
|
|||
|
||||
static uint8_t *memmem(const uint8_t *haystack, size_t haystacklen, const uint8_t *needle, size_t needlelen)
|
||||
{
|
||||
if (needlelen <= haystacklen)
|
||||
if (needlelen)
|
||||
{
|
||||
haystacklen -= needlelen-1;
|
||||
while (haystacklen--)
|
||||
if (needlelen <= haystacklen)
|
||||
{
|
||||
if (!memcmp(haystack, needle, needlelen))
|
||||
haystacklen -= needlelen-1;
|
||||
while (haystacklen--)
|
||||
{
|
||||
return((uint8_t *)haystack);
|
||||
if (!memcmp(haystack, needle, needlelen))
|
||||
{
|
||||
return((uint8_t *)haystack);
|
||||
}
|
||||
++haystack;
|
||||
}
|
||||
++haystack;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return((uint8_t *)haystack);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue