Commit 3e0cf2a1 by Ben Straub

Stop being crazy about freeing memory

parent 0afe9996
...@@ -246,21 +246,6 @@ static git_blame_hunk* hunk_from_entry(struct blame_entry *e) ...@@ -246,21 +246,6 @@ static git_blame_hunk* hunk_from_entry(struct blame_entry *e)
return h; 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) static int walk_and_mark(git_blame *blame)
{ {
int error; int error;
...@@ -269,7 +254,6 @@ static int walk_and_mark(git_blame *blame) ...@@ -269,7 +254,6 @@ static int walk_and_mark(git_blame *blame)
struct blame_entry *ent = NULL; struct blame_entry *ent = NULL;
git_blob *blob = NULL; git_blob *blob = NULL;
struct origin *o; struct origin *o;
git_vector already = GIT_VECTOR_INIT;
if ((error = git_commit_lookup(&sb.final, blame->repository, &blame->options.newest_commit)) < 0 || 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) (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) ...@@ -289,26 +273,18 @@ static int walk_and_mark(git_blame *blame)
assign_blame(&sb, blame->options.flags); assign_blame(&sb, blame->options.flags);
coalesce(&sb); coalesce(&sb);
for (ent = sb.ent; ent; ) {
git_vector_insert(&blame->hunks, hunk_from_entry(ent));
ent = ent->next;
}
cleanup: cleanup:
for (ent = sb.ent; ent; ) { for (ent = sb.ent; ent; ) {
struct blame_entry *e = ent->next; struct blame_entry *e = ent->next;
struct origin *o = ent->suspect; struct origin *o = ent->suspect;
/* Linkages might not be ordered, so we only free pointers we haven't git_vector_insert(&blame->hunks, hunk_from_entry(ent));
* seen before. */
free_if_not_already_freed(&already, o);
origin_decref(o);
git__free(ent); git__free(ent);
ent = e; ent = e;
} }
git_vector_free(&already);
git_commit_free(sb.final);
git_blob_free(blob); git_blob_free(blob);
return error; return error;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment