Implement malloc and calloc using mmap and munmap system calls
Yes, It tracks whatever has been allocated. The search uses O(n) linear search, similar to insertion and deletion.
Include in project. Please add -lrt
.
Included main.c
is an example program demonstrating the functions
Compiling the example:
gcc -g -I include src/mapmanagement.c main.c -o main.out -lrc
./main.out
void* smalloc(size_t size)
void* scalloc(size_t size, int nmemb)
Sets the data values to zero, mandatorily
void sfree(void* ptr)
Only smalloc-ed or scalloc-ed variables are freed. This way, there is no:
- Double frees
- freeing null
- freeing random locations
void spurge()
Clean all allocated memory. Implemented because it was possible.