summaryrefslogtreecommitdiffstats
path: root/benchmark/dict_bench.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-12-17 17:09:10 -0500
committerDavid Robillard <d@drobilla.net>2021-12-17 17:09:10 -0500
commit20bc5fe0759bbf313a242cb51ef8bf33736e506b (patch)
treec7fac0ca4f2c67ac807e10139b04960732c13fbd /benchmark/dict_bench.c
parentb805b7a50fc5d37c322d2f73d1e3a980b25d8369 (diff)
downloadzix-20bc5fe0759bbf313a242cb51ef8bf33736e506b.tar.gz
zix-20bc5fe0759bbf313a242cb51ef8bf33736e506b.tar.bz2
zix-20bc5fe0759bbf313a242cb51ef8bf33736e506b.zip
Fix memory leaks in dictionary benchmark
Diffstat (limited to 'benchmark/dict_bench.c')
-rw-r--r--benchmark/dict_bench.c9
1 files changed, 9 insertions, 0 deletions
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;
}