forked from KolibriOS/kolibrios
libc.obj: update malloc/free/realloc
гавно говна, нужно доработать
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user