Back to problems

Implement a memory allocator with malloc/free

Object-Oriented Programming · OpenAI · Medium

Simplified Memory Allocator — Design and Implementation Before diving into the algorithms, two design decisions fix the semantics for every approach below. Pointer representation. A pointer is the integer start index of the block that malloc handed out. Alongside the free-space structures we keep a live map from start index to block length. That map is the source of truth for free: a pointer is valid exactly when it is a key of live. This rejects unknown addresses, interior…

Checking your access…