]> git.sesse.net Git - plocate/commitdiff
Fix some Valgrind issues in plocate-build.
authorSteinar H. Gunderson <steinar+git@gunderson.no>
Thu, 8 Oct 2020 20:51:04 +0000 (22:51 +0200)
committerSteinar H. Gunderson <steinar+git@gunderson.no>
Thu, 8 Oct 2020 20:53:40 +0000 (22:53 +0200)
plocate-build.cpp

index e273e6ca79e6d369e959ba1c3e0df4b264e25ce4..be8a818a868e9f796dd836361349c6031c684467 100644 (file)
@@ -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);