From 05e1fedcc9cd30d1a34a65e640da45e980b4f859 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Thu, 19 Sep 2019 19:56:59 +0200 Subject: Moved source to kernel directory --- src/kernel/lib/memory.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/kernel/lib/memory.c (limited to 'src/kernel/lib/memory.c') diff --git a/src/kernel/lib/memory.c b/src/kernel/lib/memory.c new file mode 100644 index 0000000..e306ada --- /dev/null +++ b/src/kernel/lib/memory.c @@ -0,0 +1,26 @@ +#include "../graphics/graphics.h" + +void *memory_copy(void *dest, const void *src, size_t count) { + const char *sp = (const char *) src; + char *dp = (char *) dest; + for (; count != 0; count--) *dp++ = *sp++; + return dest; +} + +void *memory_set(void *dest, char val, size_t count) { + char *temp = (char *) dest; + for (; count != 0; count--) *temp++ = val; + return dest; +} + +int memory_compare(const void *a_ptr, const void *b_ptr, size_t size) { + const unsigned char *a = (const unsigned char *) a_ptr; + const unsigned char *b = (const unsigned char *) b_ptr; + for (size_t i = 0; i < size; i++) { + if (a[i] < b[i]) + return -1; + else if (b[i] < a[i]) + return 1; + } + return 0; +} \ No newline at end of file -- cgit v1.2.3