summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: de551d4)
raw | patch | inline | side by side (parent: de551d4)
author | Linus Torvalds <torvalds@linux-foundation.org> | |
Fri, 10 Apr 2009 22:20:18 +0000 (15:20 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 12 Apr 2009 21:30:31 +0000 (14:30 -0700) |
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 <gitster@pobox.com>
>
> 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 <gitster@pobox.com>
builtin-pack-objects.c | patch | blob | history |
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 84a13c7ccd4c04df2d45b7130ef7005643e42cb6..a6adc8c271e20374b86462391016897f1d17a0f3 100644 (file)
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
add_preferred_base_object(p->name);
add_object_entry(p->item->sha1, p->item->type, p->name, 0);
p->item->flags |= OBJECT_ADDED;
+ free((char *)p->name);
+ p->name = NULL;
}
static void show_edge(struct commit *commit)