mirror of https://github.com/kiwix/libkiwix.git
+ fix a memory leak (caused by a regression during the code refactoring)
This commit is contained in:
parent
69586116ed
commit
dd4913a77c
|
@ -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 */
|
||||
|
|
|
@ -1,17 +1,7 @@
|
|||
#ifndef KIWIX_XAPIAN_INDEXER_H
|
||||
#define KIWIX_XAPIAN_INDEXER_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#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"
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue