Skip to content

Commit 353f565

Browse files
René Scharfegitster
authored andcommitted
bisect: use leak_pending flag
Instead of creating a copy of the list of pending objects, copy the struct object_array that points to it, turn on leak_pending, and thus cause prepare_revision_walk to leave it to us. And free it once we're done. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 4a43d37 commit 353f565

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

bisect.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -823,12 +823,14 @@ static int check_ancestors(const char *prefix)
823823
bisect_rev_setup(&revs, prefix, "^%s", "%s", 0);
824824

825825
/* Save pending objects, so they can be cleaned up later. */
826-
memset(&pending_copy, 0, sizeof(pending_copy));
827-
for (i = 0; i < revs.pending.nr; i++)
828-
add_object_array(revs.pending.objects[i].item,
829-
revs.pending.objects[i].name,
830-
&pending_copy);
826+
pending_copy = revs.pending;
827+
revs.leak_pending = 1;
831828

829+
/*
830+
* bisect_common calls prepare_revision_walk right away, which
831+
* (together with .leak_pending = 1) makes us the sole owner of
832+
* the list of pending objects.
833+
*/
832834
bisect_common(&revs);
833835
res = (revs.commits != NULL);
834836

@@ -837,6 +839,7 @@ static int check_ancestors(const char *prefix)
837839
struct object *o = pending_copy.objects[i].item;
838840
clear_commit_marks((struct commit *)o, ALL_REV_FLAGS);
839841
}
842+
free(pending_copy.objects);
840843

841844
return res;
842845
}

0 commit comments

Comments
 (0)