t/helper: fix leaks in "reach" test tool
The "reach" test tool doesn't bother to clean up any of its allocated resources, causing various leaks. Plug them. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
5f5dd8e297
commit
ee3e8c3afa
@@ -127,10 +127,12 @@ int cmd__reach(int ac, const char **av)
|
|||||||
exit(128);
|
exit(128);
|
||||||
printf("%s(A,X):\n", av[1]);
|
printf("%s(A,X):\n", av[1]);
|
||||||
print_sorted_commit_ids(list);
|
print_sorted_commit_ids(list);
|
||||||
|
free_commit_list(list);
|
||||||
} else if (!strcmp(av[1], "reduce_heads")) {
|
} else if (!strcmp(av[1], "reduce_heads")) {
|
||||||
struct commit_list *list = reduce_heads(X);
|
struct commit_list *list = reduce_heads(X);
|
||||||
printf("%s(X):\n", av[1]);
|
printf("%s(X):\n", av[1]);
|
||||||
print_sorted_commit_ids(list);
|
print_sorted_commit_ids(list);
|
||||||
|
free_commit_list(list);
|
||||||
} else if (!strcmp(av[1], "can_all_from_reach")) {
|
} else if (!strcmp(av[1], "can_all_from_reach")) {
|
||||||
printf("%s(X,Y):%d\n", av[1], can_all_from_reach(X, Y, 1));
|
printf("%s(X,Y):%d\n", av[1], can_all_from_reach(X, Y, 1));
|
||||||
} else if (!strcmp(av[1], "can_all_from_reach_with_flag")) {
|
} else if (!strcmp(av[1], "can_all_from_reach_with_flag")) {
|
||||||
@@ -153,6 +155,7 @@ int cmd__reach(int ac, const char **av)
|
|||||||
filter.with_commit_tag_algo = 0;
|
filter.with_commit_tag_algo = 0;
|
||||||
|
|
||||||
printf("%s(_,A,X,_):%d\n", av[1], commit_contains(&filter, A, X, &cache));
|
printf("%s(_,A,X,_):%d\n", av[1], commit_contains(&filter, A, X, &cache));
|
||||||
|
clear_contains_cache(&cache);
|
||||||
} else if (!strcmp(av[1], "get_reachable_subset")) {
|
} else if (!strcmp(av[1], "get_reachable_subset")) {
|
||||||
const int reachable_flag = 1;
|
const int reachable_flag = 1;
|
||||||
int i, count = 0;
|
int i, count = 0;
|
||||||
@@ -176,7 +179,14 @@ int cmd__reach(int ac, const char **av)
|
|||||||
die(_("too many commits marked reachable"));
|
die(_("too many commits marked reachable"));
|
||||||
|
|
||||||
print_sorted_commit_ids(list);
|
print_sorted_commit_ids(list);
|
||||||
|
free_commit_list(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
object_array_clear(&X_obj);
|
||||||
|
strbuf_release(&buf);
|
||||||
|
free_commit_list(X);
|
||||||
|
free_commit_list(Y);
|
||||||
|
free(X_array);
|
||||||
|
free(Y_array);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
test_description='basic commit reachability tests'
|
test_description='basic commit reachability tests'
|
||||||
|
|
||||||
|
TEST_PASSES_SANITIZE_LEAK=true
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
# Construct a grid-like commit graph with points (x,y)
|
# Construct a grid-like commit graph with points (x,y)
|
||||||
|
|||||||
Reference in New Issue
Block a user