diff options
author | David Robillard <d@drobilla.net> | 2021-12-17 17:09:10 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2021-12-17 17:09:10 -0500 |
commit | 20bc5fe0759bbf313a242cb51ef8bf33736e506b (patch) | |
tree | c7fac0ca4f2c67ac807e10139b04960732c13fbd | |
parent | b805b7a50fc5d37c322d2f73d1e3a980b25d8369 (diff) | |
download | zix-20bc5fe0759bbf313a242cb51ef8bf33736e506b.tar.gz zix-20bc5fe0759bbf313a242cb51ef8bf33736e506b.tar.bz2 zix-20bc5fe0759bbf313a242cb51ef8bf33736e506b.zip |
Fix memory leaks in dictionary benchmark
-rw-r--r-- | benchmark/dict_bench.c | 9 |
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; } |