diff options
Diffstat (limited to 'src/lib/libkogata/malloc.c')
-rw-r--r-- | src/lib/libkogata/malloc.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/lib/libkogata/malloc.c b/src/lib/libkogata/malloc.c index 2a3345f..3777123 100644 --- a/src/lib/libkogata/malloc.c +++ b/src/lib/libkogata/malloc.c @@ -1,6 +1,8 @@ #include <malloc.h> #include <slab_alloc.h> +#include <string.h> + #include <syscall.h> #include <region_alloc.h> @@ -50,9 +52,17 @@ void malloc_setup() { } void* malloc(size_t size) { + if (size == 0) return 0; + return slab_alloc(mem_allocator, size); } +void* calloc(size_t nmemb, size_t sz) { + void* r = malloc(nmemb * sz); + if (r != 0) memset(r, 0, nmemb * sz); + return r; +} + void free(void* ptr) { slab_free(mem_allocator, ptr); } |