malloc/calloc/free and minimal allocator testing
[lugburz] / src / amiga / libc / malloc.c
diff --git a/src/amiga/libc/malloc.c b/src/amiga/libc/malloc.c
new file mode 100644 (file)
index 0000000..104d7bc
--- /dev/null
@@ -0,0 +1,21 @@
+#include <stdlib.h>
+#include <string.h>
+#include "mem.h"
+
+void *malloc(size_t sz)
+{
+       return mem_alloc(sz, 0);
+}
+
+void *calloc(size_t n, size_t sz)
+{
+       void *p = mem_alloc(n * sz, 0);
+       if(!p) return 0;
+       memset(p, 0, n * sz);
+       return p;
+}
+
+void free(void *p)
+{
+       mem_free(p);
+}