summaryrefslogtreecommitdiffstats
path: root/template.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2005-02-22 16:24:49 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2005-02-22 16:24:49 +0000
commit7ac6b3d6d0c387738a388790ba7b51b3dcf176fc (patch)
tree054e0442481800503c2633854c1b6d51b278901d /template.c
parent1d9fd143b71847c2bb17d0fc3989fdd59c68dddd (diff)
downloadrsyslog-7ac6b3d6d0c387738a388790ba7b51b3dcf176fc.tar.gz
rsyslog-7ac6b3d6d0c387738a388790ba7b51b3dcf176fc.tar.xz
rsyslog-7ac6b3d6d0c387738a388790ba7b51b3dcf176fc.zip
memory leak fixed
Diffstat (limited to 'template.c')
-rw-r--r--template.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/template.c b/template.c
index 73b7bcf8..2193b276 100644
--- a/template.c
+++ b/template.c
@@ -155,7 +155,7 @@ static int do_Constant(char **pp, struct template *pTpl)
pTpe->eEntryType = CONSTANT;
pTpe->data.constant.pConstant = sbStrBFinish(pStrB);
/* we need to call strlen() below because of the escape sequneces.
- * due to them p -*pp is NOT the rigt size!
+ * due to them p -*pp is NOT the right size!
*/
pTpe->data.constant.iLenConstant = strlen(pTpe->data.constant.pConstant);
@@ -442,6 +442,49 @@ struct template *tplFind(char *pName, int iLenName)
return(pTpl);
}
+/* Destroy the template structure. This is for de-initialization
+ * at program end. Everything is deleted.
+ * rgerhards 2005-02-22
+ */
+void tplDeleteAll(void)
+{
+ struct template *pTpl, *pTplDel;
+ struct templateEntry *pTpe, *pTpeDel;
+
+ pTpl = tplRoot;
+ while(pTpl != NULL) {
+ dprintf("Delete Template: Name='%s'\n ", pTpl->pszName == NULL? "NULL" : pTpl->pszName);
+ pTpe = pTpl->pEntryRoot;
+ while(pTpe != NULL) {
+ pTpeDel = pTpe;
+ pTpe = pTpe->pNext;
+ dprintf("\tDelete Entry(%x): type %d, ", (unsigned) pTpeDel, pTpeDel->eEntryType);
+ switch(pTpeDel->eEntryType) {
+ case UNDEFINED:
+ dprintf("(UNDEFINED)");
+ break;
+ case CONSTANT:
+ dprintf("(CONSTANT), value: '%s'",
+ pTpeDel->data.constant.pConstant);
+ free(pTpeDel->data.constant.pConstant);
+ break;
+ case FIELD:
+ dprintf("(FIELD), value: '%s'", pTpeDel->data.field.pPropRepl);
+ free(pTpeDel->data.field.pPropRepl);
+ break;
+ }
+ dprintf("\n");
+ free(pTpeDel);
+ }
+ pTplDel = pTpl;
+ pTpl = pTpl->pNext;
+ if(pTplDel->pszName != NULL)
+ free(pTplDel->pszName);
+ free(pTplDel);
+ }
+}
+
+
/* Print the template structure. This is more or less a
* debug or test aid, but anyhow I think it's worth it...
*/