@@ -739,11 +739,12 @@ static int add_ref_to_list(const char *refname,
739
739
void write_commit_graph_reachable (const char * obj_dir , int append ,
740
740
int report_progress )
741
741
{
742
- struct string_list list ;
742
+ struct string_list list = STRING_LIST_INIT_DUP ;
743
743
744
- string_list_init (& list , 1 );
745
744
for_each_ref (add_ref_to_list , & list );
746
745
write_commit_graph (obj_dir , NULL , & list , append , report_progress );
746
+
747
+ string_list_clear (& list , 0 );
747
748
}
748
749
749
750
void write_commit_graph (const char * obj_dir ,
@@ -768,7 +769,7 @@ void write_commit_graph(const char *obj_dir,
768
769
return ;
769
770
770
771
oids .nr = 0 ;
771
- oids .alloc = approximate_object_count () / 4 ;
772
+ oids .alloc = approximate_object_count () / 32 ;
772
773
oids .progress = NULL ;
773
774
oids .progress_done = 0 ;
774
775
@@ -813,6 +814,7 @@ void write_commit_graph(const char *obj_dir,
813
814
die (_ ("error opening index for %s" ), packname .buf );
814
815
for_each_object_in_pack (p , add_packed_commits , & oids , 0 );
815
816
close_pack (p );
817
+ free (p );
816
818
}
817
819
stop_progress (& oids .progress );
818
820
strbuf_release (& packname );
@@ -895,9 +897,11 @@ void write_commit_graph(const char *obj_dir,
895
897
compute_generation_numbers (& commits , report_progress );
896
898
897
899
graph_name = get_commit_graph_filename (obj_dir );
898
- if (safe_create_leading_directories (graph_name ))
900
+ if (safe_create_leading_directories (graph_name )) {
901
+ UNLEAK (graph_name );
899
902
die_errno (_ ("unable to create leading directories of %s" ),
900
903
graph_name );
904
+ }
901
905
902
906
hold_lock_file_for_update (& lk , graph_name , LOCK_DIE_ON_ERROR );
903
907
f = hashfd (lk .tempfile -> fd , lk .tempfile -> filename .buf );
@@ -942,9 +946,9 @@ void write_commit_graph(const char *obj_dir,
942
946
finalize_hashfile (f , NULL , CSUM_HASH_IN_STREAM | CSUM_FSYNC );
943
947
commit_lock_file (& lk );
944
948
949
+ free (graph_name );
950
+ free (commits .list );
945
951
free (oids .list );
946
- oids .alloc = 0 ;
947
- oids .nr = 0 ;
948
952
}
949
953
950
954
#define VERIFY_COMMIT_GRAPH_ERROR_HASH 2
0 commit comments