X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=lib%2Fmemcmp.c;fp=lib%2Fmemcmp.c;h=0000000000000000000000000000000000000000;hb=b7a32e2d73e3ab1add8208d3e157f7269a31ef4d;hp=b89b875e4bc11e525d50d7b234b16503ee3e1d8e;hpb=ac902a8299ff4469b356836f431ead31c3377377;p=innduct.git diff --git a/lib/memcmp.c b/lib/memcmp.c deleted file mode 100644 index b89b875..0000000 --- a/lib/memcmp.c +++ /dev/null @@ -1,42 +0,0 @@ -/* $Id: memcmp.c 5049 2001-12-12 09:06:00Z rra $ -** -** Replacement for a missing or broken memcmp. -** -** Written by Russ Allbery -** This work is hereby placed in the public domain by its author. -** -** Provides the same functionality as the standard library routine memcmp -** for those platforms that don't have it or where it doesn't work right -** (such as on SunOS where it can't deal with eight-bit characters). -*/ - -#include "config.h" -#include - -/* If we're running the test suite, rename memcmp to avoid conflicts with - the system version. */ -#if TESTING -# define memcmp test_memcmp -int test_memcmp(const void *, const void *, size_t); -#endif - -int -memcmp(const void *s1, const void *s2, size_t n) -{ - size_t i; - const unsigned char *p1, *p2; - - /* It's technically illegal to call memcmp with NULL pointers, but we - may as well check anyway. */ - if (!s1) - return !s2 ? 0 : -1; - if (!s2) - return 1; - - p1 = (const unsigned char *) s1; - p2 = (const unsigned char *) s2; - for (i = 0; i < n; i++, p1++, p2++) - if (*p1 != *p2) - return (int) *p1 - (int) *p2; - return 0; -}