diff options
Diffstat (limited to 'src/object.c')
-rw-r--r-- | src/object.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/object.c b/src/object.c index de02ef5f2..7891893a0 100644 --- a/src/object.c +++ b/src/object.c @@ -277,7 +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); + GIT_OBJECT_INCREF(repo, object); return GIT_SUCCESS; } @@ -330,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); - GIT_OBJECT_INCREF(object); + GIT_OBJECT_INCREF(repo, object); *object_out = object; return GIT_SUCCESS; } @@ -384,15 +384,6 @@ void git_object__free(git_object *object) git_object__source_close(object); - 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) { case GIT_OBJ_COMMIT: git_commit__free((git_commit *)object); @@ -421,8 +412,18 @@ void git_object_close(git_object *object) if (object == NULL) return; - if (--object->refcount <= 0) + if (--object->refcount <= 0) { + 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); + } + } + git_object__free(object); + } } const git_oid *git_object_id(const git_object *obj) |