X Tutup
Skip to content

geeksprogramming/malloc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

malloc: Dynamic Memory Allocator in C

This project implements a custom dynamic memory allocator in C that provides implementations of malloc, free, realloc, and calloc using segregated free lists and explicit free list pointers to manage free blocks. It ensures 16-byte aligned payloads, uses footer-based boundary tags for block metadata, and applies a first-fit search within size-segregated lists for allocation. The allocator performs heap consistency checks that verify free block markings, coalescing correctness, free list reachability, and absence of overlapping blocks. It relies on a simulated memory system (memlib) to model heap growth and memory operations. This project serves as a practical example of dynamic memory management and allocator design in C.

Output

s1

Support routines

The memlib.c package simulates the memory system for the dynamic memory allocator.

Example Usage

mm_init(); // Initialize the heap

void* p1 = malloc(32);
void* p2 = malloc(64);

free(p1);

void* p3 = realloc(p2, 128);

mm_checkheap(__LINE__); // Optional: check heap health

This project demonstrates a hands-on understanding of low-level memory management, pointer arithmetic, and system-level C programming.

About

Custom dynamic memory allocator in C with segregated free lists and explicit free list management. Implements malloc, free, realloc, and calloc.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

X Tutup