diff options
author | Ben Straub <bs@github.com> | 2013-09-19 10:27:37 -0700 |
---|---|---|
committer | Ben Straub <bs@github.com> | 2013-09-19 10:27:37 -0700 |
commit | 3e0cf2a18057af11e7d8ba43bb43c4b399f89a27 (patch) | |
tree | 9ebdd1afb4a4578a3c6157a2c8852ba2a6d6c79c /src/blame.c | |
parent | 0afe9996483387d282821958974320078923306c (diff) | |
download | libgit2-3e0cf2a18057af11e7d8ba43bb43c4b399f89a27.tar.gz |
Stop being crazy about freeing memory
Diffstat (limited to 'src/blame.c')
-rw-r--r-- | src/blame.c | 28 |
1 files changed, 2 insertions, 26 deletions
diff --git a/src/blame.c b/src/blame.c index 30d65f02c..33477d619 100644 --- a/src/blame.c +++ b/src/blame.c @@ -246,21 +246,6 @@ static git_blame_hunk* hunk_from_entry(struct blame_entry *e) return h; } -static void free_if_not_already_freed(git_vector *already, struct origin *o) -{ - size_t i; - - if (!o) return; - if (!git_vector_search(&i, already, o)) - return; - - git_vector_insert(already, o); - free_if_not_already_freed(already, o->previous); - git_blob_free(o->blob); - git_commit_free(o->commit); - git__free(o); -} - static int walk_and_mark(git_blame *blame) { int error; @@ -269,7 +254,6 @@ static int walk_and_mark(git_blame *blame) struct blame_entry *ent = NULL; git_blob *blob = NULL; struct origin *o; - git_vector already = GIT_VECTOR_INIT; if ((error = git_commit_lookup(&sb.final, blame->repository, &blame->options.newest_commit)) < 0 || (error = git_object_lookup_bypath((git_object**)&blob, (git_object*)sb.final, blame->path, GIT_OBJ_BLOB)) < 0) @@ -289,26 +273,18 @@ static int walk_and_mark(git_blame *blame) assign_blame(&sb, blame->options.flags); coalesce(&sb); - for (ent = sb.ent; ent; ) { - git_vector_insert(&blame->hunks, hunk_from_entry(ent)); - ent = ent->next; - } - cleanup: for (ent = sb.ent; ent; ) { struct blame_entry *e = ent->next; struct origin *o = ent->suspect; - /* Linkages might not be ordered, so we only free pointers we haven't - * seen before. */ - free_if_not_already_freed(&already, o); + git_vector_insert(&blame->hunks, hunk_from_entry(ent)); + origin_decref(o); git__free(ent); ent = e; } - git_vector_free(&already); - git_commit_free(sb.final); git_blob_free(blob); return error; } |