libc.obj: update malloc/free/realloc

гавно говна, нужно доработать
This commit is contained in:
2026-01-14 00:03:55 +05:00
parent 8322ec954b
commit bb59eac8d6
4 changed files with 200 additions and 5 deletions
@@ -1,7 +1,17 @@
#include <stdlib.h>
#include <sys/ksys.h>
#include <string.h>
#include "_mem.h"
void* realloc(void* ptr, size_t newsize)
{
return _ksys_realloc(ptr, newsize);
void *new_ptr = malloc(newsize);
if(ptr != NULL && new_ptr != NULL)
{
memcpy(new_ptr, ptr, min(newsize, GET_mem_node_HEADER(ptr)->size));
free(ptr);
}
return new_ptr;
}