diff options
author | Vicent Marti <tanoku@gmail.com> | 2011-03-01 01:37:28 +0200 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2011-03-03 20:23:53 +0200 |
commit | 584f49a5ceff463581f7f1b8bc23880dabca27ac (patch) | |
tree | a57c65fd2e530c2b096285c8625d62ea13685451 /src/object.c | |
parent | 971c90befe4dfac4c235fa59d65f7e652fc27e1d (diff) | |
download | libgit2-584f49a5ceff463581f7f1b8bc23880dabca27ac.tar.gz |
Fix several issues with refcounting
- Added several missing reference increases
- Add new destructor to the repository that does not GC the objects
Signed-off-by: Vicent Marti <tanoku@gmail.com>
Diffstat (limited to 'src/object.c')
-rw-r--r-- | src/object.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/object.c b/src/object.c index e23271442..de02ef5f2 100644 --- a/src/object.c +++ b/src/object.c @@ -277,6 +277,7 @@ int git_object_lookup(git_object **object_out, git_repository *repo, const git_o object = git_hashtable_lookup(repo->objects, id); if (object != NULL) { *object_out = object; + GIT_OBJECT_INCREF(object); return GIT_SUCCESS; } @@ -329,7 +330,7 @@ int git_object_lookup(git_object **object_out, git_repository *repo, const git_o git_object__source_close(object); git_hashtable_insert(repo->objects, &object->id, object); - object->refcount++; + GIT_OBJECT_INCREF(object); *object_out = object; return GIT_SUCCESS; } @@ -383,11 +384,13 @@ void git_object__free(git_object *object) git_object__source_close(object); - if (object->in_memory) { - int idx = git_vector_search(&object->repo->memory_objects, object); - git_vector_remove(&object->repo->memory_objects, idx); - } else { - git_hashtable_remove(object->repo->objects, &object->id); + if (object->repo != NULL) { + if (object->in_memory) { + int idx = git_vector_search(&object->repo->memory_objects, object); + git_vector_remove(&object->repo->memory_objects, idx); + } else { + git_hashtable_remove(object->repo->objects, &object->id); + } } switch (object->source.raw.type) { |