Changeset 8424


Ignore:
Timestamp:
May 19, 2009, 4:48:33 AM (12 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.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/configure.ac

    r8382 r8424  
    8888             AC_MSG_RESULT([yes])],
    8989            [AC_MSG_RESULT([no])])
    90 AC_CHECK_FUNCS([lrintf strlcpy daemon dirname basename daemon strcasecmp localtime_r posix_fallocate])
     90AC_CHECK_FUNCS([lrintf strlcpy daemon dirname basename daemon strcasecmp localtime_r posix_fallocate memmem])
    9191AC_PROG_INSTALL
    9292AC_PROG_MAKE_SET
  • trunk/libtransmission/rpc-server.c

    r8414 r8424  
    133133
    134134    tr_releaseBuffer( body );
    135 }
    136 
    137 static const char*
    138 tr_memmem( const char * s1, size_t l1, /* haystack */
    139            const char * s2, size_t l2 ) /* needle */
    140 {
    141     if( !l2 ) return s1;
    142     while( l1 >= l2 )
    143     {
    144         l1--;
    145         if( !memcmp( s1, s2, l2 ) )
    146             return s1;
    147         s1++;
    148     }
    149 
    150     return NULL;
    151135}
    152136
  • 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
  • trunk/libtransmission/utils.h

    r8389 r8424  
    351351char*       tr_strstrip( char * str );
    352352
     353const char* tr_memmem( const char * haystack, size_t haystack_len,
     354                       const char * needle, size_t needle_len );
     355
    353356/***
    354357****
Note: See TracChangeset for help on using the changeset viewer.