summaryrefslogtreecommitdiff
path: root/t/unit-tests
diff options
context:
space:
mode:
authorChandra Pratap <chandrapratap3519@gmail.com>2024-08-13 20:04:48 +0530
committerJunio C Hamano <gitster@pobox.com>2024-08-13 10:08:02 -0700
commit3dd4fb13a080ba9cbcf047e94b7fc4ed35b6153e (patch)
tree9a07eb886a2adeaa98349ea591d7543aad33201b /t/unit-tests
parent5b539a53613355a22f5c525eebdd9117fdaedb90 (diff)
t-reftable-readwrite: use free_names() instead of a for loop
free_names() as defined by reftable/basics.{c,h} frees a NULL terminated array of malloced strings along with the array itself. Use this function instead of a for loop to free such an array. Mentored-by: Patrick Steinhardt <ps@pks.im> Mentored-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/unit-tests')
-rw-r--r--t/unit-tests/t-reftable-readwrite.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/t/unit-tests/t-reftable-readwrite.c b/t/unit-tests/t-reftable-readwrite.c
index d0eb85fc38..8e546b0dd6 100644
--- a/t/unit-tests/t-reftable-readwrite.c
+++ b/t/unit-tests/t-reftable-readwrite.c
@@ -7,6 +7,7 @@ https://developers.google.com/open-source/licenses/bsd
*/
#include "test-lib.h"
+#include "reftable/basics.h"
#include "reftable/blocksource.h"
#include "reftable/reader.h"
#include "reftable/reftable-error.h"
@@ -413,7 +414,6 @@ static void t_table_read_api(void)
struct reftable_reader rd = { 0 };
struct reftable_block_source source = { 0 };
int err;
- int i;
struct reftable_log_record log = { 0 };
struct reftable_iterator it = { 0 };
@@ -432,10 +432,8 @@ static void t_table_read_api(void)
check_int(err, ==, REFTABLE_API_ERROR);
strbuf_release(&buf);
- for (i = 0; i < N; i++)
- reftable_free(names[i]);
+ free_names(names);
reftable_iterator_destroy(&it);
- reftable_free(names);
reader_close(&rd);
strbuf_release(&buf);
}
@@ -498,9 +496,7 @@ static void t_table_read_write_seek(int index, int hash_id)
reftable_iterator_destroy(&it);
strbuf_release(&buf);
- for (i = 0; i < N; i++)
- reftable_free(names[i]);
- reftable_free(names);
+ free_names(names);
reader_close(&rd);
}