pack-bitmap.c: more aggressively free in free_bitmap_index()
The function free_bitmap_index() is somewhat lax in what it frees. There are two notable examples: - While it does call kh_destroy_oid_map on the "bitmaps" map, which maps commit OIDs to their corresponding bitmaps, the bitmaps themselves are not freed. Note here that we recycle already-freed ewah_bitmaps into a pool, but these are handled correctly by ewah_pool_free(). - We never bother to free the extended index's "positions" map, which we always allocate in load_bitmap(). Fix both of these. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Taylor Blau committed
Oct 26, 2021 at 17:01 UTC
655b8561d6b10f22f0e7350df9388110667001af
1 file changed
+8
pack-bitmap.c
+8
@@ -1859,9 +1859,17 @@ void free_bitmap_index(struct bitmap_index *b)
1859
ewah_pool_free(b->trees);
1860
ewah_pool_free(b->blobs);
1861
ewah_pool_free(b->tags);
1862
+ if (b->bitmaps) {
1863
+ struct stored_bitmap *sb;
1864
+ kh_foreach_value(b->bitmaps, sb, {
1865
+ ewah_pool_free(sb->root);
1866
+ free(sb);
1867
+ });
1868
+ }
1869
kh_destroy_oid_map(b->bitmaps);
1870
free(b->ext_index.objects);
1871
free(b->ext_index.hashes);
1872
+ kh_destroy_oid_pos(b->ext_index.positions);
1873
bitmap_free(b->result);
1874
bitmap_free(b->haves);
1875
if (bitmap_is_midx(b)) {