(trunk) dht seems to be crashing in bcmp() on the mac, so I suspect the homegrown implementation of memmem() is buggy... test this out by replacing memmem()'s implementation

This commit is contained in:
Charles Kerr
2009-05-22 05:35:51 +00:00
parent 0b7007088b
commit 66da41e517
3 changed files with 27 additions and 2 deletions

View File

@@ -695,7 +695,11 @@ tr_memmem( const char * haystack, size_t haystacklen,
return memmem( haystack, haystacklen, needle, needlelen );
#else
size_t i;
for( i=0; i<haystacklen-needlelen; ++i )
if( !needlelen )
return haystack;
if( needlelen > haystacklen || !haystack || !needle )
return NULL;
for( i=0; i<=haystacklen-needlelen; ++i )
if( !memcmp( haystack+i, needle, needlelen ) )
return haystack+i;
return NULL;