Ignore:
Timestamp:
May 19, 2009, 4:48:33 AM (13 years ago)
Author:
charles
Message:

(trunk libT) expose tr_memmem() so it can be used by client code. use the OS' implementation if that's available.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/utils.c

    r8389 r8424  
    682682
    683683    return out;
     684}
     685
     686const char*
     687tr_memmem( const char * s1, size_t l1, /* haystack */
     688           const char * s2, size_t l2 ) /* needle */
     689{
     690#ifdef HAVE_MEMMEM
     691    return memmem( s1, l1, s2, l2 );
     692#else
     693    if( !l2 ) return s1;
     694    while( l1 >= l2 )
     695    {
     696        l1--;
     697        if( !memcmp( s1, s2, l2 ) )
     698            return s1;
     699        s1++;
     700    }
     701    return NULL;
     702#endif
    684703}
    685704
Note: See TracChangeset for help on using the changeset viewer.