malloc functions in there.
"./core/math/*.e",
"./core/ctype/*.c",
"./core/misc/*.c",
- "./errno/*.c",
- "./malloc/*.c",
+ "./sys/malloc/*.c",
"./signal/*.c",
"./assert/*.c",
"./stdio/*.c",
deps = {
"lang/cem/libcc.ansi/headers+pkg",
"plat/"..plat.."/include+pkg",
- "./malloc/malloc.h",
+ "./sys/malloc/malloc.h",
"./core/math/localmath.h",
"./core/stdlib/ext_fmt.h",
"./stdio/loc_incl.h",
--- /dev/null
+The functions here all use Posix system calls to do the actual work, and so
+require `unistd.h` (at the minimum). Typically each group of functions will
+be protected by an `ACKCONF` variable so the plat can turn them on and off as
+necessary.
#include <unistd.h>
#include <string.h>
+#if ACKCONF_WANT_MALLOC
+
void* calloc(size_t nmemb, size_t size)
{
size_t bytes = nmemb * size;
memset(ptr, 0, bytes);
return ptr;
}
+
+#endif
#include <unistd.h>
#include "malloc.h"
+#if ACKCONF_WANT_MALLOC
+
block_t __mem_root = { &__mem_root, 0 };
block_t* __mem_freelist = &__mem_root;
/* ...and update the ring pointer. */
__mem_freelist = p;
}
+
+#endif
#include <string.h>
#include "malloc.h"
+#if ACKCONF_WANT_MALLOC
+
void* realloc(void* ptr, size_t size)
{
block_t* h;
free(ptr);
return newptr;
}
+
+#endif