+ fix a memory leak (caused by a regression during the code refactoring)

This commit is contained in:
kelson42 2010-11-02 16:19:40 +00:00
parent 69586116ed
commit dd4913a77c
2 changed files with 15 additions and 19 deletions

View File

@ -31,10 +31,14 @@ namespace kiwix {
this->writableDatabase->begin_transaction(true); this->writableDatabase->begin_transaction(true);
} }
void XapianIndexer::indexNextArticle(string &url, string &title, string &unaccentedTitle, void XapianIndexer::indexNextArticle(const string &url,
string &keywords, string &content) { const string &title,
const string &unaccentedTitle,
const string &keywords,
const string &content) {
/* Put the data in the document */ /* Put the data in the document */
Xapian::Document currentDocument;
currentDocument.clear_values(); currentDocument.clear_values();
currentDocument.add_value(0, title); currentDocument.add_value(0, title);
currentDocument.set_data(url); currentDocument.set_data(url);
@ -42,17 +46,17 @@ namespace kiwix {
/* Index the title */ /* Index the title */
if (!unaccentedTitle.empty()) { if (!unaccentedTitle.empty()) {
indexer.index_text_without_positions(unaccentedTitle, 5); this->indexer.index_text_without_positions(unaccentedTitle, content.size() / 500 + 1);
} }
/* Index the keywords */ /* Index the keywords */
if (!keywords.empty()) { if (!keywords.empty()) {
indexer.index_text_without_positions(keywords, 3); this->indexer.index_text_without_positions(keywords, 3);
} }
/* Index the content */ /* Index the content */
if (!content.empty()) { if (!content.empty()) {
indexer.index_text_without_positions(content); this->indexer.index_text_without_positions(content);
} }
/* add to the database */ /* add to the database */

View File

@ -1,17 +1,7 @@
#ifndef KIWIX_XAPIAN_INDEXER_H #ifndef KIWIX_XAPIAN_INDEXER_H
#define KIWIX_XAPIAN_INDEXER_H #define KIWIX_XAPIAN_INDEXER_H
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <xapian.h> #include <xapian.h>
#include <unaccent.h>
#include <zim/file.h>
#include <zim/article.h>
#include <zim/fileiterator.h>
#include "xapian/myhtmlparse.h"
#include "indexer.h" #include "indexer.h"
using namespace std; using namespace std;
@ -25,8 +15,11 @@ namespace kiwix {
protected: protected:
void indexNextPercentPre(); void indexNextPercentPre();
void indexNextArticle(string &url, string &title, string &unaccentedTitle, void indexNextArticle(const string &url,
string &keywords, string &content); const string &title,
const string &unaccentedTitle,
const string &keywords,
const string &content);
void indexNextPercentPost(); void indexNextPercentPost();
void stopIndexing(); void stopIndexing();
@ -34,7 +27,6 @@ namespace kiwix {
Xapian::Stem stemmer; Xapian::Stem stemmer;
Xapian::SimpleStopper stopper; Xapian::SimpleStopper stopper;
Xapian::TermGenerator indexer; Xapian::TermGenerator indexer;
Xapian::Document currentDocument;
}; };
} }