[hackers] [scc] [libc] Add memcmp() || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Fri, 17 Feb 2017 08:47:29 +0100 (CET)

commit 92efbe7e846d7326ffbe076a99fb682172039261
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Fri Feb 17 08:40:40 2017 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Fri Feb 17 08:40:40 2017 +0100

    [libc] Add memcmp()

diff --git a/libc/src/Makefile b/libc/src/Makefile
index 6f54f53..9b9564b 100644
--- a/libc/src/Makefile
+++ b/libc/src/Makefile
_AT_@ -3,7 +3,7 @@
 
 LIBCOBJ = assert.o strcpy.o strcmp.o strlen.o strchr.o \
           strrchr.o strcat.o strncpy.o strncat.o \
- memset.o memcpy.o memmove.o
+ memset.o memcpy.o memmove.o memcmp.o
 
 all: libc.a
 
diff --git a/libc/src/memcmp.c b/libc/src/memcmp.c
new file mode 100644
index 0000000..737e0e8
--- /dev/null
+++ b/libc/src/memcmp.c
_AT_@ -0,0 +1,13 @@
+/* See LICENSE file for copyright and license details. */
+
+#include <string.h>
+
+int
+memcmp(const void *s1, const void *s2, size_t n)
+{
+ char *s = (char *) s1, *t = (char *) s2;
+
+ while (n > 0 && *s++ != *t++)
+ --n;
+ return n != 0;
+}
Received on Fri Feb 17 2017 - 08:47:29 CET

This archive was generated by hypermail 2.3.0 : Fri Feb 17 2017 - 08:48:23 CET