]> git.ipfire.org Git - thirdparty/git.git/commit
bloom: introduce `deinit_bloom_filters()`
authorTaylor Blau <me@ttaylorr.com>
Tue, 25 Jun 2024 17:40:15 +0000 (13:40 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 25 Jun 2024 20:52:06 +0000 (13:52 -0700)
commit9c8a9ec787149dc4f4b278d9bd8ad94c96691a5f
treeaa85a3b02f7778ae2db9d9c8af222d9fcf241680
parent5421e7c3a119bc869c25e2e3d5692c86bb8aa5d9
bloom: introduce `deinit_bloom_filters()`

After we are done using Bloom filters, we do not currently clean up any
memory allocated by the commit slab used to store those filters in the
first place.

Besides the bloom_filter structures themselves, there is mostly nothing
to free() in the first place, since in the read-only path all Bloom
filter's `data` members point to a memory mapped region in the
commit-graph file itself.

But when generating Bloom filters from scratch (or initializing
truncated filters) we allocate additional memory to store the filter's
data.

Keep track of when we need to free() this additional chunk of memory by
using an extra pointer `to_free`. Most of the time this will be NULL
(indicating that we are representing an existing Bloom filter stored in
a memory mapped region). When it is non-NULL, free it before discarding
the Bloom filters slab.

Suggested-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
bloom.c
bloom.h
commit-graph.c