mpool
An overhead free aligned memory allocator (Well, almost overhead free) I designed this memory allocator for a Linux device driver I wrote 20 years ago . It has the property that if you ask for 64 bytes you get a 64 byte aligned block; if you ask for 128, you get a 128 byte aligned block; and so on. The other nice thing about it is that it automatically defragments, which is to say that if, for example, a 128 byte aligned 128 byte block is free then it can be allocated as a 128 byte block, even if it one or both halves have previously been allocated as 64 byte blocks and later freed. The key to the design is the data structure. Each free block has a 64 byte header consisting of 16 pointers (I wrote this for a 32-bit architecture, although it could easily be ported). For this reason 64 bytes is the smallest block size that can be allocated. The pointers are all either NULL or point to another free block of the same size, forming a 16-ary ...