is there malloc/realloc/free implementation can specify memory region manage memory allocation?
i mean regular malloc (etc.) functions manages heap memory region. if need allocate space in shared memory segment or in memory mapped file?
not 100 %, per question want maintain own memory region. need go own my_malloc
, my_realloc
, my_free
implementing own
my_malloc
may youvoid* my_malloc(int size) { char* ptr = malloc(size+sizeof(int)); memcpy(ptr, &size, sizeof(int)); return ptr+sizeof(int); }
this small idea, full implementation take answer.
use same method achieve my_realloc
, my_free
Comments
Post a Comment