|
|
|
|
|
by unwind
529 days ago
|
|
Next question: why are there two calls to `malloc()`, one for the Pool structure and one for the Chunks? It is trivial to co-allocate them which removes the risk of memory fragmentation and is just generally a good idea if you're chasing performance. The answer might be "for clarity/simplicity" which I guess is fine in an informative article, but it could at least be highlighted in the text which I didn't see. |
|
A C11 implementation could go one step further and use _Alignas(max_align_t) to keep the pool array aligned with no manual effort. The double allocation does this implicitly.