From dd4913a77c8da6498403b9d224c0e77424c03b36 Mon Sep 17 00:00:00 2001 From: kelson42 Date: Tue, 2 Nov 2010 16:19:40 +0000 Subject: [PATCH] + fix a memory leak (caused by a regression during the code refactoring) --- src/common/kiwix/xapianIndexer.cpp | 16 ++++++++++------ src/common/kiwix/xapianIndexer.h | 18 +++++------------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/common/kiwix/xapianIndexer.cpp b/src/common/kiwix/xapianIndexer.cpp index 8c182842d..12308d68e 100644 --- a/src/common/kiwix/xapianIndexer.cpp +++ b/src/common/kiwix/xapianIndexer.cpp @@ -31,10 +31,14 @@ namespace kiwix { this->writableDatabase->begin_transaction(true); } - void XapianIndexer::indexNextArticle(string &url, string &title, string &unaccentedTitle, - string &keywords, string &content) { - + void XapianIndexer::indexNextArticle(const string &url, + const string &title, + const string &unaccentedTitle, + const string &keywords, + const string &content) { + /* Put the data in the document */ + Xapian::Document currentDocument; currentDocument.clear_values(); currentDocument.add_value(0, title); currentDocument.set_data(url); @@ -42,17 +46,17 @@ namespace kiwix { /* Index the title */ if (!unaccentedTitle.empty()) { - indexer.index_text_without_positions(unaccentedTitle, 5); + this->indexer.index_text_without_positions(unaccentedTitle, content.size() / 500 + 1); } /* Index the keywords */ if (!keywords.empty()) { - indexer.index_text_without_positions(keywords, 3); + this->indexer.index_text_without_positions(keywords, 3); } /* Index the content */ if (!content.empty()) { - indexer.index_text_without_positions(content); + this->indexer.index_text_without_positions(content); } /* add to the database */ diff --git a/src/common/kiwix/xapianIndexer.h b/src/common/kiwix/xapianIndexer.h index bb4aafd34..1f2ef4f53 100644 --- a/src/common/kiwix/xapianIndexer.h +++ b/src/common/kiwix/xapianIndexer.h @@ -1,17 +1,7 @@ #ifndef KIWIX_XAPIAN_INDEXER_H #define KIWIX_XAPIAN_INDEXER_H -#include -#include -#include -#include - #include -#include -#include -#include -#include -#include "xapian/myhtmlparse.h" #include "indexer.h" using namespace std; @@ -25,8 +15,11 @@ namespace kiwix { protected: void indexNextPercentPre(); - void indexNextArticle(string &url, string &title, string &unaccentedTitle, - string &keywords, string &content); + void indexNextArticle(const string &url, + const string &title, + const string &unaccentedTitle, + const string &keywords, + const string &content); void indexNextPercentPost(); void stopIndexing(); @@ -34,7 +27,6 @@ namespace kiwix { Xapian::Stem stemmer; Xapian::SimpleStopper stopper; Xapian::TermGenerator indexer; - Xapian::Document currentDocument; }; }