[fbreader] Fixed a few memory leaks
This commit is contained in:
parent
24749c646a
commit
c49d8af7a3
5 changed files with 27 additions and 9 deletions
|
@ -422,6 +422,14 @@ XHTMLTagAction *XHTMLReader::addAction(const std::string &tag, XHTMLTagAction *a
|
||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void XHTMLReader::clearTagTable() {
|
||||||
|
ActionMap::iterator it = ourTagActions.begin();
|
||||||
|
while (it != ourTagActions.end()) {
|
||||||
|
delete it->second;
|
||||||
|
ourTagActions.erase(it++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void XHTMLReader::fillTagTable() {
|
void XHTMLReader::fillTagTable() {
|
||||||
if (ourTagActions.empty()) {
|
if (ourTagActions.empty()) {
|
||||||
//addAction("html", new XHTMLTagAction());
|
//addAction("html", new XHTMLTagAction());
|
||||||
|
@ -480,7 +488,6 @@ void XHTMLReader::fillTagTable() {
|
||||||
addAction("br", new XHTMLTagLineBreakAction());
|
addAction("br", new XHTMLTagLineBreakAction());
|
||||||
//addAction("center", new XHTMLTagAction());
|
//addAction("center", new XHTMLTagAction());
|
||||||
addAction("div", new XHTMLTagParagraphAction());
|
addAction("div", new XHTMLTagParagraphAction());
|
||||||
addAction("dt", new XHTMLTagParagraphAction());
|
|
||||||
//addAction("head", new XHTMLTagAction());
|
//addAction("head", new XHTMLTagAction());
|
||||||
//addAction("hr", new XHTMLTagAction());
|
//addAction("hr", new XHTMLTagAction());
|
||||||
addAction("link", new XHTMLTagLinkAction());
|
addAction("link", new XHTMLTagLinkAction());
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2004-2010 Geometer Plus <contact@geometerplus.com>
|
* Copyright (C) 2004-2010 Geometer Plus <contact@geometerplus.com>
|
||||||
|
* Copyright (C) 2016-2018 Slava Monich <slava.monich@jolla.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -56,9 +57,11 @@ class XHTMLReader : public ZLXMLReader {
|
||||||
public:
|
public:
|
||||||
static XHTMLTagAction *addAction(const std::string &tag, XHTMLTagAction *action);
|
static XHTMLTagAction *addAction(const std::string &tag, XHTMLTagAction *action);
|
||||||
static void fillTagTable();
|
static void fillTagTable();
|
||||||
|
static void clearTagTable();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::map<std::string,XHTMLTagAction*> ourTagActions;
|
typedef std::map<std::string,XHTMLTagAction*> ActionMap;
|
||||||
|
static ActionMap ourTagActions;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
XHTMLReader(BookReader &modelReader);
|
XHTMLReader(BookReader &modelReader);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2009-2010 Geometer Plus <contact@geometerplus.com>
|
* Copyright (C) 2009-2010 Geometer Plus <contact@geometerplus.com>
|
||||||
|
* Copyright (C) 2016-2018 Slava Monich <slava.monich@jolla.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -137,3 +138,9 @@ void Tag::setTagId(shared_ptr<Tag> tag, int tagId) {
|
||||||
tag->myTagId = tagId;
|
tag->myTagId = tagId;
|
||||||
ourTagsById[tagId] = tag;
|
ourTagsById[tagId] = tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Tag::clearTags()
|
||||||
|
{
|
||||||
|
ourRootTags.clear();
|
||||||
|
ourTagsById.clear();
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2009-2010 Geometer Plus <contact@geometerplus.com>
|
* Copyright (C) 2009-2010 Geometer Plus <contact@geometerplus.com>
|
||||||
|
* Copyright (C) 2016-2018 Slava Monich <slava.monich@jolla.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -37,6 +38,7 @@ public:
|
||||||
static shared_ptr<Tag> getTag(const std::string &name, shared_ptr<Tag> parent = 0, int tagId = 0);
|
static shared_ptr<Tag> getTag(const std::string &name, shared_ptr<Tag> parent = 0, int tagId = 0);
|
||||||
static shared_ptr<Tag> getTagByFullName(const std::string &fullName);
|
static shared_ptr<Tag> getTagByFullName(const std::string &fullName);
|
||||||
static shared_ptr<Tag> getTagById(int tagId);
|
static shared_ptr<Tag> getTagById(int tagId);
|
||||||
|
static void clearTags();
|
||||||
|
|
||||||
static void setTagId(shared_ptr<Tag>, int tagId);
|
static void setTagId(shared_ptr<Tag>, int tagId);
|
||||||
|
|
||||||
|
|
|
@ -143,15 +143,14 @@ MyOneByteEncodingConverter::MyOneByteEncodingConverter(const std::string &encodi
|
||||||
myEncodingMap = new char[1024];
|
myEncodingMap = new char[1024];
|
||||||
memset(myEncodingMap, '\0', 1024);
|
memset(myEncodingMap, '\0', 1024);
|
||||||
for (int i = 0; i < 256; ++i) {
|
for (int i = 0; i < 256; ++i) {
|
||||||
ZLUnicodeUtil::ucs4ToUtf8(myEncodingMap + 4 * i, i);
|
if (encodingMap[i]) {
|
||||||
}
|
strcpy(myEncodingMap + 4 * i, encodingMap[i]);
|
||||||
if (encodingMap != 0) {
|
delete[] encodingMap[i];
|
||||||
for (int i = 0; i < 256; ++i) {
|
} else {
|
||||||
if (encodingMap[i] != 0) {
|
ZLUnicodeUtil::ucs4ToUtf8(myEncodingMap + 4 * i, i);
|
||||||
strcpy(myEncodingMap + 4 * i, encodingMap[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
delete[] encodingMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
MyOneByteEncodingConverter::~MyOneByteEncodingConverter() {
|
MyOneByteEncodingConverter::~MyOneByteEncodingConverter() {
|
||||||
|
|
Loading…
Reference in a new issue