From: Steinar H. Gunderson Date: Thu, 8 Oct 2020 20:51:04 +0000 (+0200) Subject: Fix some Valgrind issues in plocate-build. X-Git-Tag: 1.0.0~28 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=1b0b1f79f9b101e1592cbd186629d57e9eb50cca;p=plocate Fix some Valgrind issues in plocate-build. --- diff --git a/plocate-build.cpp b/plocate-build.cpp index e273e6c..be8a818 100644 --- a/plocate-build.cpp +++ b/plocate-build.cpp @@ -144,7 +144,9 @@ void PostingListBuilder::write_header(uint32_t docid) class Corpus { public: Corpus(FILE *outfp, size_t block_size) - : invindex(new PostingListBuilder *[NUM_TRIGRAMS]), outfp(outfp), block_size(block_size) {} + : invindex(new PostingListBuilder *[NUM_TRIGRAMS]), outfp(outfp), block_size(block_size) { + fill(invindex.get(), invindex.get() + NUM_TRIGRAMS, nullptr); + } void add_file(string filename); void flush_block(); @@ -364,6 +366,7 @@ void do_build(const char *infile, const char *outfile, int block_size) hdr.version = -1; // Mark as broken. hdr.hashtable_size = 0; // Not known yet. hdr.extra_ht_slots = num_overflow_slots; + hdr.num_docids = 0; hdr.hash_table_offset_bytes = -1; // We don't know these offsets yet. hdr.filename_index_offset_bytes = -1; fwrite(&hdr, sizeof(hdr), 1, outfp);