Currently, all state that relates to loose objects is held directly by
the `struct odb_source`. Introduce a new `struct odb_source_loose` to
hold the state instead so that it is entirely self-contained.
This structure will eventually morph into the backend for accessing
loose objects. As such, this is part of the refactorings to introduce
pluggable object databases.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
transaction->odb->transaction = NULL;
free(transaction);
}
+
+struct odb_source_loose *odb_source_loose_new(struct odb_source *source)
+{
+ struct odb_source_loose *loose;
+ CALLOC_ARRAY(loose, 1);
+ loose->source = source;
+ return loose;
+}
+
+void odb_source_loose_free(struct odb_source_loose *loose)
+{
+ free(loose);
+}
struct odb_source;
+struct odb_source_loose {
+ struct odb_source *source;
+};
+
+struct odb_source_loose *odb_source_loose_new(struct odb_source *source);
+void odb_source_loose_free(struct odb_source_loose *loose);
+
/*
* Populate and return the loose object cache array corresponding to the
* given object ID.
source->odb = odb;
source->local = local;
source->path = xstrdup(path);
+ source->loose = odb_source_loose_new(source);
return source;
}
static void odb_source_free(struct odb_source *source)
{
free(source->path);
+ odb_source_loose_free(source->loose);
odb_clear_loose_cache(source);
loose_object_map_clear(&source->loose_map);
free(source);
/* Object database that owns this object source. */
struct object_database *odb;
+ /* Private state for loose objects. */
+ struct odb_source_loose *loose;
+
/*
* Used to store the results of readdir(3) calls when we are OK
* sacrificing accuracy due to races for speed. That includes