diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/memory/memory.c | 18 | ||||
-rw-r--r-- | src/memory/memory.h | 6 |
2 files changed, 13 insertions, 11 deletions
diff --git a/src/memory/memory.c b/src/memory/memory.c index 3524787..f36c0bc 100644 --- a/src/memory/memory.c +++ b/src/memory/memory.c @@ -1,16 +1,14 @@ #include "../graphics/vga.h" -unsigned char *memory_copy(unsigned char *dest, const unsigned char *src, int count) { - // TODO: Add memory copy function +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; } -unsigned char *memory_set(unsigned char *dest, unsigned char val, int count) { - unsigned char *p = dest; - while (count > 0) { - if (!*p) break; - *p = val; - p++; - count--; - } +void *memory_set(void *dest, char val, size_t count) { + char *temp = (char *) dest; + for (; count != 0; count--) *temp++ = val; return dest; } diff --git a/src/memory/memory.h b/src/memory/memory.h index 9e2374d..d605299 100644 --- a/src/memory/memory.h +++ b/src/memory/memory.h @@ -1,6 +1,10 @@ #ifndef MELVIX_MEMORY_H #define MELVIX_MEMORY_H -unsigned char *memory_set(unsigned char *dest, unsigned char val, int count); +#include <stddef.h> + +void *memory_copy(void *dest, const void *src, size_t count); + +void *memory_set(void *dest, char val, size_t count); #endif |