From 453e83d1cf862c27a468a50e6f3cea7f803bc501 Mon Sep 17 00:00:00 2001 From: Jonas Gunz Date: Sun, 19 Sep 2021 22:17:21 +0200 Subject: tests/tree.c: fix compiler warnings --- tests/tree.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/tree.c b/tests/tree.c index 42bf248..ccfb3fe 100644 --- a/tests/tree.c +++ b/tests/tree.c @@ -15,16 +15,19 @@ START_TEST(tree_basic) { unsigned const int len = pow ( 'z' - 'a' + 1, 2); unsigned int len_cnt = 0; - char* keys[len]; - char* data[len]; + char** keys; + char** data; struct tree_node* root = NULL; + keys = malloc(len * sizeof(char*)); + data = malloc(len * sizeof(char*)); + for ( i = 'a'; i <= 'z'; i++ ) { for ( j = 'a'; j <= 'z'; j++ ) { keys[len_cnt] = malloc (3); - keys[len_cnt][0] = i; - keys[len_cnt][1] = j; + keys[len_cnt][0] = (char)i; + keys[len_cnt][1] = (char)j; keys[len_cnt][2] = 0; data[len_cnt] = malloc(10); @@ -41,6 +44,9 @@ START_TEST(tree_basic) { } ck_assert_int_eq( tree_destroy (&root, _TREE_FREE_DATA | _TREE_FREE_KEY), 0 ); + + free(keys); + free(data); } END_TEST TCase* test_tree(void) { -- cgit v1.2.3