aboutsummaryrefslogtreecommitdiff
path: root/src/lib/libkogata/malloc.c
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2016-07-14 11:45:11 +0200
committerAlex Auvolat <alex@adnab.me>2016-07-14 11:45:11 +0200
commit2f13288a23da4dfaf6c40e1e943f83d8fa43145a (patch)
tree3b550ad22a00676470ceb2815afd21f42dfd8aae /src/lib/libkogata/malloc.c
parent477911553e0443fcafad5bd96c97314aa2f8d9ea (diff)
downloadkogata-2f13288a23da4dfaf6c40e1e943f83d8fa43145a.tar.gz
kogata-2f13288a23da4dfaf6c40e1e943f83d8fa43145a.zip
Fix sme warnings...
Diffstat (limited to 'src/lib/libkogata/malloc.c')
-rw-r--r--src/lib/libkogata/malloc.c10
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);
}