pack-bitmap: introduce bitmap_writer_free()

Now that there is clearer memory ownership around the bitmap_writer
structure, introduce a bitmap_writer_free() function that callers may
use to free any memory associated with their instance of the
bitmap_writer structure.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Taylor Blau
2024-05-14 15:57:06 -04:00
committed by Junio C Hamano
parent f25e1f2a4d
commit 85f360fee5
4 changed files with 27 additions and 1 deletions

View File

@ -32,6 +32,29 @@ void bitmap_writer_init(struct bitmap_writer *writer)
memset(writer, 0, sizeof(struct bitmap_writer));
}
void bitmap_writer_free(struct bitmap_writer *writer)
{
uint32_t i;
if (!writer)
return;
ewah_free(writer->commits);
ewah_free(writer->trees);
ewah_free(writer->blobs);
ewah_free(writer->tags);
kh_destroy_oid_map(writer->bitmaps);
for (i = 0; i < writer->selected_nr; i++) {
struct bitmapped_commit *bc = &writer->selected[i];
if (bc->write_as != bc->bitmap)
ewah_free(bc->write_as);
ewah_free(bc->bitmap);
}
free(writer->selected);
}
void bitmap_writer_show_progress(struct bitmap_writer *writer, int show)
{
writer->show_progress = show;