Skip to content

Commit 97501e9

Browse files
stefanbellergitster
authored andcommitted
object-store: free alt_odb_list
Free the memory and reset alt_odb_{list, tail} to NULL. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 031dc92 commit 97501e9

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

object.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,30 @@ struct raw_object_store *raw_object_store_new(void)
454454
memset(o, 0, sizeof(*o));
455455
return o;
456456
}
457+
458+
static void free_alt_odb(struct alternate_object_database *alt)
459+
{
460+
strbuf_release(&alt->scratch);
461+
oid_array_clear(&alt->loose_objects_cache);
462+
free(alt);
463+
}
464+
465+
static void free_alt_odbs(struct raw_object_store *o)
466+
{
467+
while (o->alt_odb_list) {
468+
struct alternate_object_database *next;
469+
470+
next = o->alt_odb_list->next;
471+
free_alt_odb(o->alt_odb_list);
472+
o->alt_odb_list = next;
473+
}
474+
}
475+
457476
void raw_object_store_clear(struct raw_object_store *o)
458477
{
459478
FREE_AND_NULL(o->objectdir);
460479
FREE_AND_NULL(o->alternate_db);
480+
481+
free_alt_odbs(o);
482+
o->alt_odb_tail = NULL;
461483
}

0 commit comments

Comments
 (0)