diff options
author | Russell Belfer <rb@github.com> | 2013-04-15 00:05:44 -0700 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2013-04-22 16:51:40 +0200 |
commit | 786062639f05e361da977f3f1f6286141fa12fca (patch) | |
tree | 5dc63d86657681572376ef2bced9bb2cae8e2213 /src/cache.c | |
parent | 917f60c50bce09f789aeb927b45ba3bca5a23877 (diff) | |
download | libgit2-786062639f05e361da977f3f1f6286141fa12fca.tar.gz |
Add callback to git_objects_table
This adds create and free callback to the git_objects_table so
that more of the creation and destruction of objects can be table
driven instead of using switch statements. This also makes the
semantics of certain object creation functions consistent so that
we can make better use of function pointers. This also fixes a
theoretical error case where an object allocation fails and we
end up storing NULL into the cache.
Diffstat (limited to 'src/cache.c')
-rw-r--r-- | src/cache.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/cache.c b/src/cache.c index 263f736fa..c51be895e 100644 --- a/src/cache.c +++ b/src/cache.c @@ -70,12 +70,6 @@ int git_cache_init(git_cache *cache) return 0; } -void git_cache_free(git_cache *cache) -{ - git_oidmap_free(cache->map); - git_mutex_free(&cache->lock); -} - void git_cache_clear(git_cache *cache) { git_cached_obj *evict = NULL; @@ -93,6 +87,14 @@ void git_cache_clear(git_cache *cache) git_mutex_unlock(&cache->lock); } +void git_cache_free(git_cache *cache) +{ + git_cache_clear(cache); + + git_oidmap_free(cache->map); + git_mutex_free(&cache->lock); +} + /* Call with lock, yo */ static void cache_evict_entries(git_cache *cache, size_t evict_count) { |