Ticket #7: dht-memmem.patch

File dht-memmem.patch, 831 bytes (added by jch, 13 years ago)
  • dht.c

    diff -rN -u old-dht/dht.c new-dht/dht.c
    old new  
    4545
    4646#include "dht.h"
    4747
     48#ifdef __GLIBC__
     49#define HAVE_MEMMEM
     50#endif
     51
    4852#ifndef MSG_CONFIRM
    4953#define MSG_CONFIRM 0
    5054#endif
     
    20792083    return -1;
    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,
    20842105              unsigned char *tid_return, int *tid_len,