From f2dc01a8dc255caff5aa907ec2c022a7ce5118b8 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 30 Mar 2018 13:47:48 -0400 Subject: [PATCH] tests: reduce malloc usage in eina_test_hash_extended ref T6839 Reviewed-by: Stefan Schmidt --- src/tests/eina/eina_test_hash.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/tests/eina/eina_test_hash.c b/src/tests/eina/eina_test_hash.c index 82eccc07a8..a9e663a6e5 100644 --- a/src/tests/eina/eina_test_hash.c +++ b/src/tests/eina/eina_test_hash.c @@ -181,24 +181,29 @@ EFL_END_TEST EFL_START_TEST(eina_test_hash_extended) { Eina_Hash *hash = NULL; - int i; + unsigned int i; + unsigned int num_loops = 3011; + char *array; hash = eina_hash_string_djb2_new(NULL); fail_if(hash == NULL); fail_if(eina_hash_direct_add(hash, "42", "42") != EINA_TRUE); - for (i = 43; i < 3043; ++i) + array = malloc(num_loops * 10); + ck_assert_ptr_nonnull(array); + + for (i = 0; i < num_loops; ++i) { - char *tmp = malloc(10); - fail_if(!tmp); - eina_convert_itoa(i, tmp); + char *tmp = array + (i * 10); + eina_convert_itoa(i + 42, tmp); fail_if(eina_hash_direct_add(hash, tmp, tmp) != EINA_TRUE); } fail_if(eina_hash_find(hash, "42") == NULL); eina_hash_free(hash); + free(array); } EFL_END_TEST