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

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-06-01 01:09:58 +0400
committerRussell Belfer <rb@github.com>2013-06-01 01:09:58 +0400
commitf658dc433cae351e72b1c8b245724eafb43f5844 (patch)
tree025948ea3b6a30c41b44d86fe4655fbeda3d578c /src/cache.c
parent17ef7dbce4e4eaa08ed7007b6d67f375759846a8 (diff)
Zero memory for major objects before freeing
By zeroing out the memory when we free larger objects (i.e. those that serve as collections of other data, such as repos, odb, refdb), I'm hoping that it will be easier for libgit2 bindings to find errors in their object management code.
Diffstat (limited to 'src/cache.c')
-rw-r--r--src/cache.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/cache.c b/src/cache.c
index dc3af063a..6205ef8a9 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -66,7 +66,7 @@ void git_cache_dump_stats(git_cache *cache)
int git_cache_init(git_cache *cache)
{
- cache->used_memory = 0;
+ memset(cache, 0, sizeof(*cache));
cache->map = git_oidmap_alloc();
git_mutex_init(&cache->lock);
return 0;
@@ -102,9 +102,9 @@ void git_cache_clear(git_cache *cache)
void git_cache_free(git_cache *cache)
{
git_cache_clear(cache);
-
git_oidmap_free(cache->map);
git_mutex_free(&cache->lock);
+ memset(cache, 0, sizeof(*cache));
}
/* Called with lock */