Skip to content

Basic implementation of malloc, free, calloc, and realloc

Notifications You must be signed in to change notification settings

layan-mak/basic-malloc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

basic-malloc

Basic implementation of malloc, free, calloc, and realloc, written in C.

About the implementation:

  • Every block has a metadata structure.
  • A global pointer to a list (by size) that will contain all the data sectors, the list is used to search for free spaces upon allocation requests, instead of increasing the program break and enlarging the heap unnecessarily.
  • Internal fragmentation avoidance: The data sectors are stored in a sorted list (by size), and allocations use the memory region with the minimal size that can fit the memory allocation. In addition, if a pre-allocated block is reused and is large enough, the block is into two smaller blocks with two separate meta-data structs
  • Use of mmap instead of sbrk for very large allocations.
  • Safety and security: Use of cookies to check if the metadata of memory blocks have changed.

Releases

No releases published

Packages

No packages published

Languages