diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2005-02-22 16:24:49 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2005-02-22 16:24:49 +0000 |
commit | 7ac6b3d6d0c387738a388790ba7b51b3dcf176fc (patch) | |
tree | 054e0442481800503c2633854c1b6d51b278901d /template.c | |
parent | 1d9fd143b71847c2bb17d0fc3989fdd59c68dddd (diff) | |
download | rsyslog-7ac6b3d6d0c387738a388790ba7b51b3dcf176fc.tar.gz rsyslog-7ac6b3d6d0c387738a388790ba7b51b3dcf176fc.tar.xz rsyslog-7ac6b3d6d0c387738a388790ba7b51b3dcf176fc.zip |
memory leak fixed
Diffstat (limited to 'template.c')
-rw-r--r-- | template.c | 45 |
1 files changed, 44 insertions, 1 deletions
@@ -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... */ |