Skip to content

Latest commit

 

History

History
23 lines (15 loc) · 772 Bytes

File metadata and controls

23 lines (15 loc) · 772 Bytes

blockfit

This repository implements a basic block-based heap allocator in C to illustrate core ideas in dynamic memory management.

The allocator manages a fixed-size heap using a doubly linked list of metadata blocks and provides heap_alloc and heap_free.

Features

  • Fixed-size heap (HEAP_SIZE)
  • Fixed-size blocks (BLOCK_SIZE)
  • Metadata stored separately from heap payload
  • First-fit contiguous block allocation
  • Allocation tracking via allocation IDs
  • Heap memory obtained using mmap

Heap Layout

A single mmap region is logically divided into:

  1. Metadata region: an array of block_metadata structures
  2. Heap region: the memory returned to the caller

Each metadata entry corresponds to exactly one fixed-size heap block.