Dynamic Storage Allocator

PREVIOUS: Project Options

The Dynamic Storage Allocator program assignment is completed in groups of two people. The program is written in C programming language and uses support functions provided by the course instructor. The program uses implicit lists and static functions instead of macros. The goal is to implement malloc, free, and realloc, of which a brief description is provided below:

malloc: Returns a pointer to an allocated block payload of at least size bytes. Returns NULL if the requested size is 0 or if mem_sbrk is unable to extend the heap.

free: Frees the block pointed to by ptr and returns nothing. Free does nothing if ptr is NULL.

realloc: Returns a pointer to an allocated region of at least size bytes with the following constraints

      • if ptr is NULL, the call is equivalent to malloc(size);
      • if size is equal to zero, the call is equivalent to free(ptr);
      • if ptr is not NULL, changes the size of the memory block pointed to by ptr (the old block) to size bytes and returns the address of the new block

This assignment is one of the earlier projects completed while first learning about the C programming language. The Dynamic Storage Allocator serves as a practice to teach the basics when students are new to the C programming language. Through this project, students became more familiar with concepts such as using pointers, pointer arithmetic, and bit manipulation.

Click HERE for Dynamic Storage Allocator Code

NEXT: Mini CPU