mirror of
https://github.com/git/git.git
synced 2024-11-08 14:09:26 +01:00
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:
parent
f25e1f2a4d
commit
85f360fee5
@ -1245,7 +1245,6 @@ static void write_pack_file(void)
|
||||
uint32_t nr_remaining = nr_result;
|
||||
time_t last_mtime = 0;
|
||||
struct object_entry **write_order;
|
||||
struct bitmap_writer bitmap_writer;
|
||||
|
||||
if (progress > pack_to_stdout)
|
||||
progress_state = start_progress(_("Writing objects"), nr_result);
|
||||
@ -1315,6 +1314,7 @@ static void write_pack_file(void)
|
||||
if (!pack_to_stdout) {
|
||||
struct stat st;
|
||||
struct strbuf tmpname = STRBUF_INIT;
|
||||
struct bitmap_writer bitmap_writer;
|
||||
char *idx_tmp_name = NULL;
|
||||
|
||||
/*
|
||||
@ -1370,6 +1370,7 @@ static void write_pack_file(void)
|
||||
bitmap_writer_finish(&bitmap_writer,
|
||||
written_list, nr_written,
|
||||
tmpname.buf, write_bitmap_options);
|
||||
bitmap_writer_free(&bitmap_writer);
|
||||
write_bitmap_index = 0;
|
||||
strbuf_setlen(&tmpname, tmpname_len);
|
||||
}
|
||||
|
@ -853,6 +853,7 @@ static int write_midx_bitmap(const char *midx_name,
|
||||
cleanup:
|
||||
free(index);
|
||||
free(bitmap_name);
|
||||
bitmap_writer_free(&writer);
|
||||
|
||||
trace2_region_leave("midx", "write_midx_bitmap", the_repository);
|
||||
|
||||
|
@ -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;
|
||||
|
@ -139,6 +139,7 @@ void bitmap_writer_finish(struct bitmap_writer *writer,
|
||||
uint32_t index_nr,
|
||||
const char *filename,
|
||||
uint16_t options);
|
||||
void bitmap_writer_free(struct bitmap_writer *writer);
|
||||
char *midx_bitmap_filename(struct multi_pack_index *midx);
|
||||
char *pack_bitmap_filename(struct packed_git *p);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user