{"thread":{"id":"2528","subject":"[PATCH] git-fsck-objects: Free tree entries after use","startedAt":"2005-11-15T16:07:15Z","lastAt":"2005-11-15T16:07:15Z","messageCount":1,"participants":["Sergey Vlasov"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"11902","messageId":"20051115160715.GF24496@master.mivlgu.local","threadId":"2528","inReplyTo":null,"subject":"[PATCH] git-fsck-objects: Free tree entries after use","fromName":"Sergey Vlasov","fromEmail":"vsu@altlinux.ru","sentAt":"2005-11-15T16:07:15Z","receivedAt":"2005-11-15T16:07:15Z","isPatch":true,"sender":{"key":"vsu@altlinux.ru","avatar":"https://avatars.githubusercontent.com/u/616082?v=4"},"body":"The Massif tool of Valgrind revealed that parsed tree entries occupy\nmore than 60% of memory allocated by git-fsck-objects.  These entries\ncan be freed immediately after use, which significantly decreases\nmemory consumption.\n\nSigned-off-by: Sergey Vlasov <vsu@altlinux.ru>\n\n\n---\n\n fsck-objects.c |    7 +++++++\n 1 files changed, 7 insertions(+), 0 deletions(-)\n\napplies-to: 4b6dbe856a3e63699b299c76f4f1fc5cb34cbe26\n0742a20134cc7f58f2c4cbc982a3eb115c6eaf47\ndiff --git a/fsck-objects.c b/fsck-objects.c\nindex 17d0536..c1b279e 100644\n--- a/fsck-objects.c\n+++ b/fsck-objects.c\n@@ -184,10 +184,17 @@ static int fsck_tree(struct tree *item)\n \t\t\tdefault:\n \t\t\t\tbreak;\n \t\t\t}\n+\t\t\tfree(last->name);\n+\t\t\tfree(last);\n \t\t}\n \n \t\tlast = entry;\n \t}\n+\tif (last) {\n+\t\tfree(last->name);\n+\t\tfree(last);\n+\t}\n+\titem->entries = NULL;\n \n \tretval = 0;\n \tif (has_full_path) {\n---\n0.99.9.GIT\n"}]}