object_array: add a "clear" function
There's currently no easy way to free the memory associated with an object_array (and in most cases, we simply leak the memory in a rev_info's pending array). Let's provide a helper to make this easier to handle. We can make use of it in list-objects.c, which does the same thing by hand (but fails to free the "name" field of each entry, potentially leaking memory). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
68f492359e
commit
46be823124
@ -228,11 +228,6 @@ void traverse_commit_list(struct rev_info *revs,
|
||||
die("unknown pending object %s (%s)",
|
||||
sha1_to_hex(obj->sha1), name);
|
||||
}
|
||||
if (revs->pending.nr) {
|
||||
free(revs->pending.objects);
|
||||
revs->pending.nr = 0;
|
||||
revs->pending.alloc = 0;
|
||||
revs->pending.objects = NULL;
|
||||
}
|
||||
object_array_clear(&revs->pending);
|
||||
strbuf_release(&base);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user