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>
Stefan Beller committed
Mar 23, 2018 at 18:20 UTC
97501e933a6d4d5a8567dbbb44fa3b4bff2ea298
1 file changed
+22
object.c
+22
@@ -454,8 +454,30 @@ struct raw_object_store *raw_object_store_new(void)
454
memset(o, 0, sizeof(*o));
455
return o;
456
}
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
+
476
void raw_object_store_clear(struct raw_object_store *o)
477
{
478
FREE_AND_NULL(o->objectdir);
479
FREE_AND_NULL(o->alternate_db);
480
+
481
+ free_alt_odbs(o);
482
+ o->alt_odb_tail = NULL;
483
}