summaryrefslogtreecommitdiff
path: root/plugins/IEView/src/Template.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-09-21 13:37:19 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-09-21 13:37:19 +0000
commit8b6824e3ec3ed7340db33bcbe592321b6afb0a00 (patch)
tree3c23f231d3126e85798f602be4b89c347d9ca36d /plugins/IEView/src/Template.cpp
parent0bb0ce1ac12784d4d119619dc6915666f590946d (diff)
- warning fixes;
- memleak fixes; - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@6154 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/IEView/src/Template.cpp')
-rw-r--r--plugins/IEView/src/Template.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/plugins/IEView/src/Template.cpp b/plugins/IEView/src/Template.cpp
index 20a3dd2cc9..158249762f 100644
--- a/plugins/IEView/src/Template.cpp
+++ b/plugins/IEView/src/Template.cpp
@@ -42,10 +42,7 @@ Token::Token(int type, const char *text, int escape)
next = NULL;
this->type = type;
this->escape = escape;
- if (text!=NULL)
- this->text = mir_strdup(text);
- else
- this->text = NULL;
+ this->text = mir_strdup(text);
}
Token::~Token()
@@ -373,10 +370,7 @@ TemplateMap* TemplateMap::loadTemplateFile(const char *id, const char *filename,
if (wasTemplate)
tmap->addTemplate(lastTemplate, templateText);
- if (templateText != NULL)
- free (templateText);
-
- templateText = NULL;
+ replaceStr(templateText, NULL);
templateTextSize = 0;
wasTemplate = true;
sscanf(store, "<!--%[^-]", lastTemplate);
@@ -386,6 +380,7 @@ TemplateMap* TemplateMap::loadTemplateFile(const char *id, const char *filename,
}
if (wasTemplate)
tmap->addTemplate(lastTemplate, templateText);
+ replaceStr(templateText, NULL);
fclose(fh);
static const char *groupTemplates[] = {"MessageInGroupStart", "MessageInGroupInner",
@@ -429,19 +424,18 @@ Template* TemplateMap::getTemplate(const char *text)
return 0;
}
-Template* TemplateMap::getTemplate(const char *proto, const char *text) {
- TemplateMap *ptr;
- for (ptr=mapList; ptr!=NULL; ptr=ptr->next) {
- if (!strcmp(ptr->name, proto)) {
+Template* TemplateMap::getTemplate(const char *proto, const char *text)
+{
+ for (TemplateMap *ptr = mapList; ptr != NULL; ptr = ptr->next)
+ if (!strcmp(ptr->name, proto))
return ptr->getTemplate(text);
- }
- }
+
return NULL;
}
TemplateMap* TemplateMap::getTemplateMap(const char *proto)
{
- for (TemplateMap *ptr=mapList; ptr != NULL; ptr = ptr->next)
+ for (TemplateMap *ptr = mapList; ptr != NULL; ptr = ptr->next)
if (!strcmp(ptr->name, proto))
return ptr;
@@ -464,4 +458,10 @@ TemplateMap* TemplateMap::loadTemplates(const char *id, const char *filename, bo
return loadTemplateFile(id, filename, onlyInfo);
}
-
+void TemplateMap::dropTemplates()
+{
+ for (TemplateMap *p = mapList, *p1; p != NULL; p = p1) {
+ p1 = p->next;
+ delete p;
+ }
+}