The goal of this exercise is to design and
implement an user-level memory management library similar
to LIBC's malloc
. Memory is allocated, released and
reallocated by this library.
At initialization, the library must allocate a
specific amount of memory from the operating system
(e.g. brk
, which is thereafter used as a buffer to
meet user requests for memory. This buffer must be managed so that
free neighbors blocks are merged together, this reducing external
fragmentation.
The user-level memory manager library must implement, at least, the following interface:
void * alloc(int size)
size
bytes of memory, returning a pointer to the
allocated area on success and "0" on failure.
void free(void * ptr)
alloc
.
void * realloc(void * ptr, int new_size)
alloc
and pointed to by ptr
to
new_size
bytes. The function returns a pointer to
the reallocated area on success and "0" on failure.
void dump(void)