diff options
author | Vicent Marti <tanoku@gmail.com> | 2011-02-28 16:51:17 +0200 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2011-03-03 20:23:52 +0200 |
commit | 48c27f86bbe9678c7e01a90a2cec7a30327b0e90 (patch) | |
tree | 0156ea823de82477792ad4778378200eee28aee3 /src/revwalk.c | |
parent | 86d7e1ca6f54161a9e4d1ebe7a2f8e4802dc9639 (diff) | |
download | libgit2-48c27f86bbe9678c7e01a90a2cec7a30327b0e90.tar.gz |
Implement reference counting for git_objects
All `git_object` instances looked up from the repository are reference
counted. User is expected to use the new `git_object_close` when an
object is no longer needed to force freeing it.
Signed-off-by: Vicent Marti <tanoku@gmail.com>
Diffstat (limited to 'src/revwalk.c')
-rw-r--r-- | src/revwalk.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/revwalk.c b/src/revwalk.c index c073be13f..872cdbc43 100644 --- a/src/revwalk.c +++ b/src/revwalk.c @@ -114,6 +114,7 @@ static git_revwalk_commit *commit_to_walkcommit(git_revwalk *walk, git_commit *c memset(commit, 0x0, sizeof(git_revwalk_commit)); commit->commit_object = commit_object; + GIT_OBJECT_INCREF(commit_object); git_hashtable_insert(walk->commits, commit_object, commit); @@ -229,6 +230,7 @@ int git_revwalk_next(git_commit **commit, git_revwalk *walk) while ((next = walk->next(&walk->iterator)) != NULL) { if (!next->uninteresting) { *commit = next->commit_object; + GIT_OBJECT_INCREF(*commit); return GIT_SUCCESS; } } @@ -246,6 +248,7 @@ void git_revwalk_reset(git_revwalk *walk) assert(walk); GIT_HASHTABLE_FOREACH(walk->commits, _unused, commit, { + git_object_close((git_object *)commit->commit_object); git_revwalk_list_clear(&commit->parents); free(commit); }); |