зеркало из https://github.com/microsoft/git.git
log: fix memory leak if --graph is passed multiple times
Signed-off-by: Alex Henrie <alexhenrie24@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
2b9c120970
Коммит
dccf6c16f1
12
graph.c
12
graph.c
|
@ -401,6 +401,18 @@ struct git_graph *graph_init(struct rev_info *opt)
|
|||
return graph;
|
||||
}
|
||||
|
||||
void graph_clear(struct git_graph *graph)
|
||||
{
|
||||
if (!graph)
|
||||
return;
|
||||
|
||||
free(graph->columns);
|
||||
free(graph->new_columns);
|
||||
free(graph->mapping);
|
||||
free(graph->old_mapping);
|
||||
free(graph);
|
||||
}
|
||||
|
||||
static void graph_update_state(struct git_graph *graph, enum graph_state s)
|
||||
{
|
||||
graph->prev_state = graph->state;
|
||||
|
|
5
graph.h
5
graph.h
|
@ -139,6 +139,11 @@ void graph_set_column_colors(const char **colors, unsigned short colors_max);
|
|||
*/
|
||||
struct git_graph *graph_init(struct rev_info *opt);
|
||||
|
||||
/*
|
||||
* Free a struct git_graph.
|
||||
*/
|
||||
void graph_clear(struct git_graph *graph);
|
||||
|
||||
/*
|
||||
* Update a git_graph with a new commit.
|
||||
* This will cause the graph to begin outputting lines for the new commit
|
||||
|
|
|
@ -2426,6 +2426,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
|
|||
} else if (!strcmp(arg, "--graph")) {
|
||||
revs->topo_order = 1;
|
||||
revs->rewrite_parents = 1;
|
||||
graph_clear(revs->graph);
|
||||
revs->graph = graph_init(revs);
|
||||
} else if (!strcmp(arg, "--encode-email-headers")) {
|
||||
revs->encode_email_headers = 1;
|
||||
|
|
Загрузка…
Ссылка в новой задаче