diff options
-rw-r--r-- | action.c | 1 | ||||
-rw-r--r-- | grammar/rainerscript.c | 41 | ||||
-rw-r--r-- | grammar/rainerscript.h | 6 | ||||
-rw-r--r-- | runtime/modules.c | 4 | ||||
-rw-r--r-- | runtime/rsconf.c | 10 |
5 files changed, 54 insertions, 8 deletions
@@ -1964,6 +1964,7 @@ dbgprintf("XXXX:actionNewInst for module '%s'/%p\n", cnfModName, pMod); dbgprintf("XXXX:actionNewInst CALLED module '%s'/%p\n", cnfModName, pMod); finalize_it: free(cnfModName); + cnfparamvalsDestruct(paramvals, ¶mblk); RETiRet; } diff --git a/grammar/rainerscript.c b/grammar/rainerscript.c index c953c840..0b2ee7cb 100644 --- a/grammar/rainerscript.c +++ b/grammar/rainerscript.c @@ -475,6 +475,7 @@ cnfactlstAddSysline(struct cnfactlst* actlst, char *line) return actlst; } + void cnfactlstDestruct(struct cnfactlst *actlst) { @@ -483,6 +484,7 @@ cnfactlstDestruct(struct cnfactlst *actlst) while(actlst != NULL) { toDel = actlst; actlst = actlst->next; + cnfcfsyslinelstDestruct(toDel->syslines); if(toDel->actType == CNFACT_V2) nvlstDestruct(toDel->data.lst); else @@ -1245,6 +1247,28 @@ cnfrulePrint(struct cnfrule *rule) dbgprintf("------ end rule %p\n", rule); } +void +cnfcfsyslinelstDestruct(struct cnfcfsyslinelst *cfslst) +{ + struct cnfcfsyslinelst *toDel; + while(cfslst != NULL) { + toDel = cfslst; + cfslst = cfslst->next; + free(toDel->line); + free(toDel); + } +} + +void +cnfruleDestruct(struct cnfrule *rule) +{ + if( rule->filttype == CNFFILT_PRI + || rule->filttype == CNFFILT_PROP) + free(rule->filt.s); + cnfactlstDestruct(rule->actlst); + free(rule); +} + struct cnffparamlst * cnffparamlstNew(struct cnfexpr *expr, struct cnffparamlst *next) { @@ -1382,6 +1406,23 @@ cnfDoInclude(char *name) return 0; } +void +varDelete(struct var *v) +{ + if(v->datatype == 'S') + es_deleteStr(v->d.estr); +} + +void +cnfparamvalsDestruct(struct cnfparamvals *paramvals, struct cnfparamblk *blk) +{ + int i; + for(i = 0 ; i < blk->nParams ; ++i) { + varDelete(¶mvals[i].val); + } + free(paramvals); +} + /* find the index (or -1!) for a config param by name. This is used to * address the parameter array. Of course, we could use with static * indices, but that would create some extra bug potential. So we diff --git a/grammar/rainerscript.h b/grammar/rainerscript.h index f7454ef5..7cc38abb 100644 --- a/grammar/rainerscript.h +++ b/grammar/rainerscript.h @@ -66,7 +66,7 @@ struct nvlst { struct nvlst *next; es_str_t *name; struct var val; - unsigned char *bUsed; + unsigned char bUsed; /**< was this node used during config processing? If not, this * indicates an error. After all, the user specified a setting * that the software does not know. @@ -234,6 +234,7 @@ int cnfexprEvalBool(struct cnfexpr *expr, void *usrptr); struct cnfnumval* cnfnumvalNew(long long val); struct cnfstringval* cnfstringvalNew(es_str_t *estr); struct cnfrule * cnfruleNew(enum cnfFiltType filttype, struct cnfactlst *actlst); +void cnfruleDestruct(struct cnfrule *rule); void cnfrulePrint(struct cnfrule *rule); struct cnfvar* cnfvarNew(char *name); struct cnffunc * cnffuncNew(es_str_t *fname, struct cnffparamlst* paramlst); @@ -243,6 +244,9 @@ int cnfparamGetIdx(struct cnfparamblk *params, char *name); struct cnfparamvals* nvlstGetParams(struct nvlst *lst, struct cnfparamblk *params, struct cnfparamvals *vals); void cnfparamsPrint(struct cnfparamblk *params, struct cnfparamvals *vals); +void varDelete(struct var *v); +void cnfparamvalsDestruct(struct cnfparamvals *paramvals, struct cnfparamblk *blk); +void cnfcfsyslinelstDestruct(struct cnfcfsyslinelst *cfslst); /* debug helper */ void cstrPrint(char *text, es_str_t *estr); diff --git a/runtime/modules.c b/runtime/modules.c index f6b4bad9..0f132bdf 100644 --- a/runtime/modules.c +++ b/runtime/modules.c @@ -240,8 +240,8 @@ static rsRetVal moduleConstruct(modInfo_t **pThis) static void moduleDestruct(modInfo_t *pThis) { assert(pThis != NULL); - if(pThis->pszName != NULL) - free(pThis->pszName); + free(pThis->pszName); + free(pThis->cnfName); if(pThis->pModHdlr != NULL) { # ifdef VALGRIND # warning "dlclose disabled for valgrind" diff --git a/runtime/rsconf.c b/runtime/rsconf.c index 4fe17534..f93bd7bc 100644 --- a/runtime/rsconf.c +++ b/runtime/rsconf.c @@ -417,26 +417,26 @@ void cnfDoRule(struct cnfrule *cnfrule) finalize_it: //TODO: do something with error states - ; + cnfruleDestruct(cnfrule); } void cnfDoCfsysline(char *ln) { - dbgprintf("cnf:global:cfsysline: %s\n", ln); + DBGPRINTF("cnf:global:cfsysline: %s\n", ln); /* the legacy system needs the "$" stripped */ conf.cfsysline((uchar*) ln+1); - dbgprintf("cnf:cfsysline call done\n"); + free(ln); /* cfsysline is just a simple string */ } void cnfDoBSDTag(char *ln) { - dbgprintf("cnf:global:BSD tag: %s\n", ln); + DBGPRINTF("cnf:global:BSD tag: %s\n", ln); cflineProcessTagSelector((uchar**)&ln); } void cnfDoBSDHost(char *ln) { - dbgprintf("cnf:global:BSD host: %s\n", ln); + DBGPRINTF("cnf:global:BSD host: %s\n", ln); cflineProcessHostSelector((uchar**)&ln); } |