math: move x87-family fabs functions to C with inline asm
[musl] / src / malloc / lite_malloc.c
index b09f30b..050d84f 100644 (file)
@@ -2,16 +2,15 @@
 #include <stdint.h>
 #include <limits.h>
 #include <errno.h>
-#include "libc.h"
+#include "lock.h"
+#include "malloc_impl.h"
 
 #define ALIGN 16
 
-void *__expand_heap(size_t *);
-
-void *__simple_malloc(size_t n)
+static void *__simple_malloc(size_t n)
 {
        static char *cur, *end;
-       static volatile int lock[2];
+       static volatile int lock[1];
        size_t align=1, pad;
        void *p;
 
@@ -47,4 +46,14 @@ void *__simple_malloc(size_t n)
 }
 
 weak_alias(__simple_malloc, malloc);
-weak_alias(__simple_malloc, malloc0);
+
+static void *__simple_calloc(size_t m, size_t n)
+{
+       if (n && m > (size_t)-1/n) {
+               errno = ENOMEM;
+               return 0;
+       }
+       return __simple_malloc(n * m);
+}
+
+weak_alias(__simple_calloc, calloc);