odb: generic in-memory source

Make the in-memory source generic. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Apr 10, 2026 at 14:12 UTC fdf74cb2cab6a4a95fd6e7e589ac6a4508bf358f
2 files changed +5 -5
odb.c
+4 -4
@@ -560,7 +560,7 @@ static int do_oid_object_info_extended(struct object_database *odb,
560 if (is_null_oid(real))
561 return -1;
562
563 - if (!odb_source_read_object_info(&odb->inmemory_objects->base, oid, oi, flags))
563 + if (!odb_source_read_object_info(odb->inmemory_objects, oid, oi, flags))
564 return 0;
565
566 odb_prepare_alternates(odb);
@@ -737,7 +737,7 @@ int odb_pretend_object(struct object_database *odb,
737 if (odb_has_object(odb, oid, 0))
738 return 0;
739
740 - return odb_source_write_object(&odb->inmemory_objects->base,
740 + return odb_source_write_object(odb->inmemory_objects,
741 buf, len, type, oid, NULL, 0);
742 }
743
@@ -1020,7 +1020,7 @@ struct object_database *odb_new(struct repository *repo,
1020 o->sources = odb_source_new(o, primary_source, true);
1021 o->sources_tail = &o->sources->next;
1022 o->alternate_db = xstrdup_or_null(secondary_sources);
1023 - o->inmemory_objects = odb_source_inmemory_new(o);
1023 + o->inmemory_objects = &odb_source_inmemory_new(o)->base;
1024
1025 free(to_free);
1026
@@ -1045,7 +1045,7 @@ static void odb_free_sources(struct object_database *o)
1045 o->sources = next;
1046 }
1047
1048 - odb_source_free(&o->inmemory_objects->base);
1048 + odb_source_free(o->inmemory_objects);
1049 o->inmemory_objects = NULL;
1050
1051 kh_destroy_odb_path_map(o->source_by_path);
odb.h
+1 -1
@@ -81,7 +81,7 @@ struct object_database {
81 * to write them into the object store (e.g. a browse-only
82 * application).
83 */
84 - struct odb_source_inmemory *inmemory_objects;
84 + struct odb_source *inmemory_objects;
85
86 /*
87 * A fast, rough count of the number of objects in the repository.