diff options
author | Paul Baltescu <pauldb89@gmail.com> | 2013-03-06 11:43:16 +0000 |
---|---|---|
committer | Paul Baltescu <pauldb89@gmail.com> | 2013-03-06 11:43:16 +0000 |
commit | 245e705ac7b6fca80a7aa4898f5467053ec2c585 (patch) | |
tree | 3034bcadfd9ed3778f1c89f5ea883270a3f64194 /extractor/precomputation.cc | |
parent | 6717daa034bfcfa429275f64d84607ae1568d488 (diff) |
Fix memory leak in trie.
Diffstat (limited to 'extractor/precomputation.cc')
-rw-r--r-- | extractor/precomputation.cc | 19 |
1 files changed, 1 insertions, 18 deletions
diff --git a/extractor/precomputation.cc b/extractor/precomputation.cc index 8a76beb1..189ac42c 100644 --- a/extractor/precomputation.cc +++ b/extractor/precomputation.cc @@ -41,7 +41,6 @@ Precomputation::Precomputation( for (int j = 1; j <= max_frequent_phrase_len && i + j <= data.size(); ++j) { pattern.push_back(data[i + j - 1]); if (frequent_patterns_set.count(pattern)) { - inverted_index[pattern].push_back(i); int is_super_frequent = super_frequent_patterns_set.count(pattern); matchings.push_back(make_tuple(i, j, is_super_frequent)); } else { @@ -158,19 +157,7 @@ void Precomputation::WriteBinary(const fs::path& filepath) const { FILE* file = fopen(filepath.string().c_str(), "w"); // TODO(pauldb): Refactor this code. - int size = inverted_index.size(); - fwrite(&size, sizeof(int), 1, file); - for (auto entry: inverted_index) { - size = entry.first.size(); - fwrite(&size, sizeof(int), 1, file); - fwrite(entry.first.data(), sizeof(int), size, file); - - size = entry.second.size(); - fwrite(&size, sizeof(int), 1, file); - fwrite(entry.second.data(), sizeof(int), size, file); - } - - size = collocations.size(); + int size = collocations.size(); fwrite(&size, sizeof(int), 1, file); for (auto entry: collocations) { size = entry.first.size(); @@ -183,10 +170,6 @@ void Precomputation::WriteBinary(const fs::path& filepath) const { } } -const Index& Precomputation::GetInvertedIndex() const { - return inverted_index; -} - const Index& Precomputation::GetCollocations() const { return collocations; } |