struct cell {
// in both cell and header
long size;
long arena;
bool used;
// not in header
cell* next;
cell* prev;
};
sizeof(cell) = 40
On AMD64, a reasonable minimum header size is 8. Pointers need to be 8-byte aligned, so using a size 8 header maintains that alignment for the pointer we return to the user.
Similarly, a reasonable minimum cell size is 16, since nobody should really expect the allocator to be efficient for allocations smaller than 8.
So let's fit in those sizes:
struct cell {
// in both cell and header
uint32_t arena; // up to 4B of them
uint8_t size; // store which power of two
uint8_t used; // used flag
uint16_t _pad;
// not in header
int32_t next; // offset from start of arena, -1 is EOL
int32_t prev; // offset from start of arena, -1 is EOL
};