From 46be823124bb6a6ff0e06dc19c327b599ed97c72 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 15 Oct 2014 18:34:34 -0400 Subject: 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 Signed-off-by: Junio C Hamano --- list-objects.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'list-objects.c') diff --git a/list-objects.c b/list-objects.c index 3595ee7a22..fad6808aad 100644 --- a/list-objects.c +++ b/list-objects.c @@ -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); } -- cgit v1.2.3