Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2017-04-16 09:41:32 +0300
committerJunio C Hamano <gitster@pobox.com>2017-04-17 07:32:46 +0300
commit7c22bc8a18744cbd79436a8ce598a0dd5d49869b (patch)
tree3daf30ca84cfb8009d6964fd4708480e22eb510d /refs/ref-cache.c
parent958f964691a250d9a7173f1c0a4c03fd9e71e2aa (diff)
ref-cache: introduce a new type, ref_cache
For now, it just wraps a `ref_entry *` that points at the root of the tree. Soon it will hold more information. Add two new functions, `create_ref_cache()` and `free_ref_cache()`. Make `free_ref_entry()` private. Change files-backend to use this type to hold its caches. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs/ref-cache.c')
-rw-r--r--refs/ref-cache.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/refs/ref-cache.c b/refs/ref-cache.c
index 4274a43a9b..bf911028c8 100644
--- a/refs/ref-cache.c
+++ b/refs/ref-cache.c
@@ -63,9 +63,17 @@ struct ref_entry *create_ref_entry(const char *refname,
return ref;
}
+struct ref_cache *create_ref_cache(struct files_ref_store *refs)
+{
+ struct ref_cache *ret = xcalloc(1, sizeof(*ret));
+
+ ret->root = create_dir_entry(refs, "", 0, 1);
+ return ret;
+}
+
static void clear_ref_dir(struct ref_dir *dir);
-void free_ref_entry(struct ref_entry *entry)
+static void free_ref_entry(struct ref_entry *entry)
{
if (entry->flag & REF_DIR) {
/*
@@ -77,6 +85,12 @@ void free_ref_entry(struct ref_entry *entry)
free(entry);
}
+void free_ref_cache(struct ref_cache *cache)
+{
+ free_ref_entry(cache->root);
+ free(cache);
+}
+
/*
* Clear and free all entries in dir, recursively.
*/