lib: c: combine libc and ulibc
libc is now made up of several independent components, each of which is individually compiled into a static library. they are then all combined into a single shared library.
This commit is contained in:
44
lib/libc/malloc/stdlib/malloc.c
Normal file
44
lib/libc/malloc/stdlib/malloc.c
Normal file
@@ -0,0 +1,44 @@
|
||||
#include <heap/heap.h>
|
||||
|
||||
#ifdef ENABLE_GLOBAL_HEAP
|
||||
static heap_t global_heap = HEAP_INIT;
|
||||
|
||||
void *malloc(size_t count)
|
||||
{
|
||||
return heap_alloc(&global_heap, count);
|
||||
}
|
||||
|
||||
void *calloc(size_t count, size_t size)
|
||||
{
|
||||
return heap_calloc(&global_heap, count, size);
|
||||
}
|
||||
|
||||
void *realloc(void *p, size_t count)
|
||||
{
|
||||
return heap_realloc(&global_heap, p, count);
|
||||
}
|
||||
|
||||
void free(void *p)
|
||||
{
|
||||
heap_free(&global_heap, p);
|
||||
}
|
||||
#else
|
||||
void *malloc(size_t count)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *calloc(size_t count, size_t size)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *realloc(void *p, size_t count)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void free(void *p)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user