Skip to content

Latest commit

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Memory Allocator (C)

A tiny, educational memory allocator that manages a fixed-size heap using a singly linked free list. It demonstrates block splitting, freeing, and coalescing with a debug heap dump.

Features

  • Fixed-size 1 MiB heap stored in a static array
  • Simple free-list allocator with block splitting
  • Coalescing of adjacent free blocks on free
  • Debug helper to print heap layout

Build

Requirements:

  • CMake 4.2 or newer
  • A C compiler that supports C11

Build steps:

cmake -S . -B build
cmake --build build

Run

./build/memory_allocator

The program runs a small allocation/free sequence and prints heap dumps after each step.

API (core functions)

voidheap_init(void);
void*xmalloc(size_tsize);
voidxfree(void*ptr);
voidheap_dump(void);

Project Layout

  • CMakeLists.txt - CMake build configuration
  • main.c - allocator implementation and demo

About

Educational C memory allocator with a fixed-size heap, free-list splitting, and coalescing demo.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages