Skip to content

rts/Hash: Simplify freeing of HashListChunks

Ben Gamari requested to merge wip/T18348 into master

While looking at #18348 (closed) I noticed that the treatment of HashLists are a bit more complex than necessary (which lead to some initial confusion on my part). Specifically, we allocate HashLists in chunks. Each chunk allocation makes two allocations: one for the chunk itself and one for a HashListChunk to link together the chunks for the purposes of freeing.

Simplify this (and hopefully make the relationship between these clearer) but allocating the HashLists and HashListChunk in a single malloc. This will both make the implementation easier to follow and reduce C heap fragmentation.

Note that even after this patch we fail to bound the size of the free HashList pool. However, this is a separate bug.

Edited by Ben Gamari

Merge request reports