From c33bc6864a3291dc72b2da071e52e481573f5459 Mon Sep 17 00:00:00 2001 From: marvinborner Date: Wed, 18 Sep 2019 11:03:36 +0200 Subject: Added missing components --- src/lib/lib.h | 8 ++++++++ src/lib/string.c | 14 ++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 src/lib/lib.h create mode 100644 src/lib/string.c (limited to 'src/lib') diff --git a/src/lib/lib.h b/src/lib/lib.h new file mode 100644 index 0000000..aa5d3bc --- /dev/null +++ b/src/lib/lib.h @@ -0,0 +1,8 @@ +#ifndef MELVIX_LIB_H +#define MELVIX_LIB_H + +size_t strlen(const char *str); + +size_t strcmp(const char *s1, const char *s2); + +#endif diff --git a/src/lib/string.c b/src/lib/string.c new file mode 100644 index 0000000..a4be160 --- /dev/null +++ b/src/lib/string.c @@ -0,0 +1,14 @@ +size_t strlen(const char *str) { + size_t len = 0; + while (str[len]) + len++; + return len; +} + +size_t strcmp(const char *s1, const char *s2) { + while (*s1 && (*s1 == *s2)) { + s1++; + s2++; + } + return *(const unsigned char*)s1 - *(const unsigned char*)s2; +} -- cgit v1.2.3