Skip to content

Amr2812/babymalloc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

babymalloc

A dynamic memory allocator in C, inspired by the CS:APP malloc lab from the CMU course Intro to Computer Systems.

Description

This is a dynamic memory allocator that utilizes simple techniques:

  • First-fit placement policy:
    • The allocator searches for the first free block that is large enough to fit the requested size.
  • Boundary tags:
    • Each block contains a header and footer that store the size of the block and whether the block is allocated or free.
    • This allows the allocator to traverse the heap in both directions.
  • Implicit free list:
    • The allocator uses a simple implicit free list to keep track of free blocks.
    • The allocator traverses the free list using the size of the blocks.
  • Immediate coalescing:
    • When a block is freed, the allocator checks if the adjacent blocks (in both sides) are free and coalesces them.
  • Splitting:
    • When a block is allocated, the allocator checks if the block is large enough to be split into two blocks.
  • sbrk:
    • The allocator uses the sbrk system call to request more memory from the kernel when the heap is full.
  • Alignment:
    • The allocator aligns the blocks to the word size of the CPU.
  • Platform Compatibility:
    • The allocator works on 64-bit, 32-bit and smaller CPUs on UNIX-like systems.

About

A dynamic memory allocator library in C

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published