mirror of
https://github.com/git-for-windows/git.git
synced 2026-04-17 16:20:48 -05:00
Implement the `free()` callback function for the "in-memory" source. Note that this requires us to define `struct cached_object_entry` in "odb/source-inmemory.h", as it is accessed in both "odb.c" and "odb/source-inmemory.c" now. This will be fixed in subsequent commits though. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
25 lines
671 B
C
25 lines
671 B
C
#include "git-compat-util.h"
|
|
#include "odb/source-inmemory.h"
|
|
|
|
static void odb_source_inmemory_free(struct odb_source *source)
|
|
{
|
|
struct odb_source_inmemory *inmemory = odb_source_inmemory_downcast(source);
|
|
for (size_t i = 0; i < inmemory->objects_nr; i++)
|
|
free((char *) inmemory->objects[i].value.buf);
|
|
free(inmemory->objects);
|
|
free(inmemory->base.path);
|
|
free(inmemory);
|
|
}
|
|
|
|
struct odb_source_inmemory *odb_source_inmemory_new(struct object_database *odb)
|
|
{
|
|
struct odb_source_inmemory *source;
|
|
|
|
CALLOC_ARRAY(source, 1);
|
|
odb_source_init(&source->base, odb, ODB_SOURCE_INMEMORY, "source", false);
|
|
|
|
source->base.free = odb_source_inmemory_free;
|
|
|
|
return source;
|
|
}
|