Good for didactic purposes but in the real world you may want to try an allocator like tcmalloc or jemalloc.
In the past I've sometimes achieved 20% or better speedups by writing custom allocators (speedup on overall performance, not just malloc performance). tcmalloc or jemalloc are great for the general case, but sometimes you know invariants about object sizes, alloc patterns and free patterns that allow much more performant allocation. The simplest case is if you know that you will free everything at once, or nothing at…
jemalloc allows you to query these invariants if you don't know them, and to use the information to re-configure the allocator to match them :/
I'm pretty sure most modern allocators allow you to do this as well.
> The simplest case is if you know that you will free everything at once, or nothing at all.
That's pretty much a one liner with jemalloc.