From 20bc5fe0759bbf313a242cb51ef8bf33736e506b Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 17 Dec 2021 17:09:10 -0500 Subject: Fix memory leaks in dictionary benchmark --- benchmark/dict_bench.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'benchmark/dict_bench.c') diff --git a/benchmark/dict_bench.c b/benchmark/dict_bench.c index a5d17a4..9044311 100644 --- a/benchmark/dict_bench.c +++ b/benchmark/dict_bench.c @@ -78,6 +78,7 @@ run(FILE* const fd) if (!new_chunks) { free(chunks); + free(buf); return 1; } @@ -96,6 +97,7 @@ run(FILE* const fd) char* const new_buf = (char*)realloc(buf, buf_len); if (!new_buf) { + free(chunks); free(buf); return 1; } @@ -178,6 +180,13 @@ run(FILE* const fd) fclose(insert_dat); fclose(search_dat); + for (size_t i = 0; i < n_chunks; ++i) { + free(chunks[i].buf); + } + + free(chunks); + free(buf); + fprintf(stderr, "Wrote dict_insert.txt dict_search.txt\n"); return 0; } -- cgit v1.2.1