From d2df6a9c064965b62c8b966bb93a81b663b35395 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sun, 14 Nov 2021 18:04:38 +0100 Subject: shared: move the str* implementations to shared/mem.c --- src/shared/mem.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/shared/mem.c') diff --git a/src/shared/mem.c b/src/shared/mem.c index 1b483fe..9185c9e 100644 --- a/src/shared/mem.c +++ b/src/shared/mem.c @@ -26,3 +26,20 @@ void *memset(void *s, int c, size_t n) { s2[i] = c; return s; } + +int strcmp(const char *s1, const char *s2) { + while (*s1) { + if (*s1 != *s2) { + if (*s1 < *s2) return -1; + else return 1; + } + s1++; s2++; + } + return 0; +} + +size_t strlen(const char *s) { + size_t c = 0; + while (*s++) c++; + return c; +} -- cgit v1.2.3