aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/core/kmalloc.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/kernel/core/kmalloc.c
parent477911553e0443fcafad5bd96c97314aa2f8d9ea (diff)
downloadkogata-2f13288a23da4dfaf6c40e1e943f83d8fa43145a.tar.gz
kogata-2f13288a23da4dfaf6c40e1e943f83d8fa43145a.zip
Fix sme warnings...
Diffstat (limited to 'src/kernel/core/kmalloc.c')
-rw-r--r--src/kernel/core/kmalloc.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/kernel/core/kmalloc.c b/src/kernel/core/kmalloc.c
index 95347b3..985df41 100644
--- a/src/kernel/core/kmalloc.c
+++ b/src/kernel/core/kmalloc.c
@@ -2,6 +2,7 @@
#include <slab_alloc.h>
#include <mutex.h>
+#include <string.h>
#include <frame.h>
#include <paging.h>
@@ -77,6 +78,8 @@ void* malloc0(size_t sz) {
}
void* malloc(size_t sz) {
+ if (sz == 0) return 0;
+
void* res;
int tries = 0;
@@ -88,6 +91,12 @@ void* malloc(size_t sz) {
return res;
}
+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) {
mutex_lock(&malloc_mutex);
slab_free(kernel_allocator, ptr);