A C++14 implementation of the buddy memory allocation algorithm.
The algorithm is encapsulated in an object which is constructed with a pointer to the memory block to be managed and its size.
Allocation and deallocation take time O(logN), where N is the first power of two greater-than or equal to the managed block's size.
In terms of memory consumption for bookkeeping, no more than 5-6% of the memory block is used for big enough blocks, say bigger than 1KB. For large blocks, say at least 4KB, the memory consumption becomes insignificantly small - around 1-2%. The algorithm is not well suited to small allocations so the second figure is more indicative.
Move operations are also supported. The object's behaviour is illustrated in its unit tests.
Documentation, notes on algorithm design, complexity and correctness can be found in the project's docs.
The project's unit tests are written with Catch2 and can be found here.
Allocation Adventures 3: The Buddy Allocator
The Art of Computer Programming, Vol. 1, Donald Knuth