Memory Allocator


My implementation of dynamic memory management routines— specifically the standard C library’s (libc) malloc(), realloc(), and free() routines— for a computer systems course. It is a first-fit allocator, which manages all pointers efficiently to prevent memory leaks and maximize utilization.


  • void *mm_malloc(size_t size) - Allocates size bytes of uninitialized storage and returns a pointer to the payload
  • void mm_free(void *ptr) - Deallocates a previously allocated block of memory, allowing it to be reused later
  • void *mm_realloc(void *ptr, size_t size) - Reallocates a previously allocated and not yet freed memory block to update it with a new given size size, by either:
    • expanding or contracting the existing block, if possible
    • allocating a new memory block, copying the existing memory area, and freeing the old block

To compile: run make in terminal directory which contains the Makefile and sh.c

Code is password-protected. To request access, email me at