1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 09:13:06 +00:00

(trunk libT) make tr_memmem() more readable

This commit is contained in:
Charles Kerr 2009-05-20 04:25:45 +00:00
parent fb77a810d7
commit af213891f9

View file

@ -688,20 +688,20 @@ tr_strndup( const void * in, int len )
}
const char*
tr_memmem( const char * s1, size_t l1, /* haystack */
const char * s2, size_t l2 ) /* needle */
tr_memmem( const char * haystack, size_t haystacklen,
const char * needle, size_t needlelen )
{
#ifdef HAVE_MEMMEM
return memmem( s1, l1, s2, l2 );
return memmem( haystack, haystacklen, needle, needlelen );
#else
if( !l2 ) return s1;
while( l1 >= l2 )
{
l1--;
if( !memcmp( s1, s2, l2 ) )
return s1;
s1++;
}
const char *h = haystack;
const char *n = needle;
size_t i;
for( i=0; i<haystacklen-needlelen; ++i )
if( !memcmp( h+i, n, needlelen ) )
return h+i;
return NULL;
#endif
}