]> Sergey Matveev's repositories - dht-bootstrap.git/commitdiff
memmem exists both on GNU and FreeBSD already
authorSergey Matveev <stargrave@stargrave.org>
Wed, 9 Nov 2022 08:43:09 +0000 (11:43 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Wed, 9 Nov 2022 10:11:18 +0000 (13:11 +0300)
dht-bootstrap.c

index a4fe67e9363ce7c698e40910ddfdb389c5478fe0..2e6e77dc25fe1aac8a5c858886a64e4b1b84554e 100644 (file)
@@ -20,9 +20,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 */
 
 THE SOFTWARE.
 */
 
-/* For memmem. */
-#define _GNU_SOURCE
-
 #include <arpa/inet.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <arpa/inet.h>
 #include <errno.h>
 #include <fcntl.h>
@@ -38,35 +35,10 @@ THE SOFTWARE.
 #include <time.h>
 #include <unistd.h>
 
 #include <time.h>
 #include <unistd.h>
 
-#ifndef HAVE_MEMMEM
-#ifdef __GLIBC__
-#define HAVE_MEMMEM
-#endif
-#endif
-
 #ifndef MSG_CONFIRM
 #define MSG_CONFIRM 0
 #endif
 
 #ifndef MSG_CONFIRM
 #define MSG_CONFIRM 0
 #endif
 
-/* We set sin_family to 0 to mark unused slots. */
-#if AF_INET == 0 || AF_INET6 == 0
-#error You lose
-#endif
-
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
-/* nothing */
-#elif defined(__GNUC__)
-#define inline __inline
-#if (__GNUC__ >= 3)
-#define restrict __restrict
-#else
-#define restrict /**/
-#endif
-#else
-#define inline   /**/
-#define restrict /**/
-#endif
-
 #define MAX(x, y) ((x) >= (y) ? (x) : (y))
 #define MIN(x, y) ((x) <= (y) ? (x) : (y))
 
 #define MAX(x, y) ((x) >= (y) ? (x) : (y))
 #define MIN(x, y) ((x) <= (y) ? (x) : (y))
 
@@ -1067,26 +1039,6 @@ fail:
 #undef COPY
 #undef ADD_V
 
 #undef COPY
 #undef ADD_V
 
-#ifndef HAVE_MEMMEM
-static void *
-memmem(const void *haystack, size_t haystacklen, const void *needle, size_t needlelen)
-{
-    const char *h = haystack;
-    const char *n = needle;
-    size_t i;
-
-    /* size_t is unsigned */
-    if (needlelen > haystacklen)
-        return NULL;
-
-    for (i = 0; i <= haystacklen - needlelen; i++) {
-        if (memcmp(h + i, n, needlelen) == 0)
-            return (void *)(h + i);
-    }
-    return NULL;
-}
-#endif
-
 static int
 parse_message(
     const unsigned char *buf,
 static int
 parse_message(
     const unsigned char *buf,