Skip to content

Commit f22ca7c

Browse files
robfitz273kJunio C Hamano
authored andcommitted
Reduce memory usage in git-update-server-info.
Modify parse_object_cheap() to also free all the entries from the tree data structures. Signed-off-by: Robert Fitzsimons <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 230f132 commit f22ca7c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

server-info.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ static struct object *parse_object_cheap(const unsigned char *sha1)
5959
struct commit *commit = (struct commit *)o;
6060
free(commit->buffer);
6161
commit->buffer = NULL;
62+
} else if (o->type == tree_type) {
63+
struct tree *tree = (struct tree *)o;
64+
struct tree_entry_list *e, *n;
65+
for (e = tree->entries; e; e = n) {
66+
free(e->name);
67+
e->name = NULL;
68+
n = e->next;
69+
free(e);
70+
}
71+
tree->entries = NULL;
6272
}
6373
return o;
6474
}

0 commit comments

Comments
 (0)