Skip to content

Commit 2131526

Browse files
torvaldsgitster
authored andcommitted
process_{tree,blob}: Remove useless xstrdup calls
On Wed, 8 Apr 2009, Björn Steinbrink wrote: > > The name of the processed object was duplicated for passing it to > add_object(), but that already calls path_name, which allocates a new > string anyway. So the memory allocated by the xstrdup calls just went > nowhere, leaking memory. Ack, ack. There's another easy 5% or so for the built-in object walker: once we've created the hash from the name, the name isn't interesting any more, and so something trivial like this can help a bit. Does it matter? Probably not on its own. But a few more memory saving tricks and it might all make a difference. Linus Signed-off-by: Junio C Hamano <[email protected]>
1 parent de551d4 commit 2131526

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

builtin-pack-objects.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1861,6 +1861,8 @@ static void show_object(struct object_array_entry *p)
18611861
add_preferred_base_object(p->name);
18621862
add_object_entry(p->item->sha1, p->item->type, p->name, 0);
18631863
p->item->flags |= OBJECT_ADDED;
1864+
free((char *)p->name);
1865+
p->name = NULL;
18641866
}
18651867

18661868
static void show_edge(struct commit *commit)

0 commit comments

Comments
 (0)