diff options
author | Dag-Erling Smørgrav <des@FreeBSD.org> | 2012-07-04 14:24:26 +0000 |
---|---|---|
committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2012-07-04 14:24:26 +0000 |
commit | afb79913ce00d885b8b43f7478e1e054edadb567 (patch) | |
tree | b9037afac70edd3c6342318cedbbadc648b799ca /compat/memcmp.c |
Diffstat (limited to 'compat/memcmp.c')
-rw-r--r-- | compat/memcmp.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/compat/memcmp.c b/compat/memcmp.c new file mode 100644 index 0000000000000..9446276f410a3 --- /dev/null +++ b/compat/memcmp.c @@ -0,0 +1,25 @@ +/* + * memcmp.c: memcmp compat implementation. + * + * Copyright (c) 2010, NLnet Labs. All rights reserved. + * + * See LICENSE for the license. +*/ + +#include <config.h> + +int memcmp(const void *x, const void *y, size_t n); + +int memcmp(const void *x, const void *y, size_t n) +{ + const uint8_t* x8 = (const uint8_t*)x; + const uint8_t* y8 = (const uint8_t*)y; + size_t i; + for(i=0; i<n; i++) { + if(x8[i] < y8[i]) + return -1; + else if(x8[i] > y8[i]) + return 1; + } + return 0; +} |