Changeset 8446


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

(trunk) #7: jch's dht-memmem.patch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/third-party/dht/dht.c

    r8440 r8446  
    4545
    4646#include "dht.h"
     47
     48#ifdef __GLIBC__
     49#define HAVE_MEMMEM
     50#endif
    4751
    4852#ifndef MSG_CONFIRM
     
    20802084}
    20812085
     2086#ifndef HAVE_MEMMEM
     2087static void *
     2088memmem(const void *haystack, size_t haystacklen,
     2089       const void *needle, size_t needlelen)
     2090{
     2091    const char *h = haystack;
     2092    const char *n = needle;
     2093    size_t i;
     2094
     2095    for(i = 0; i < haystacklen - needlelen; i++) {
     2096        if(memcmp(h + i, n, needlelen) == 0)
     2097            return h + i;
     2098    }
     2099    return NULL;
     2100}
     2101#endif
     2102
    20822103static int
    20832104parse_message(const unsigned char *buf, int buflen,
Note: See TracChangeset for help on using the changeset viewer.