summaryrefslogtreecommitdiffstats
path: root/grammar
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2011-07-21 13:55:45 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2011-07-21 13:55:45 +0200
commit63446424c057f527c9c17be7e06f306a130789b4 (patch)
treef860f85b933793bf49e26f18db33111b493f116e /grammar
parent448f2eeea247fe4bf7bbbc982fb6df0f7a1b72f9 (diff)
downloadrsyslog-63446424c057f527c9c17be7e06f306a130789b4.tar.gz
rsyslog-63446424c057f527c9c17be7e06f306a130789b4.tar.xz
rsyslog-63446424c057f527c9c17be7e06f306a130789b4.zip
fixing minor memory leaks
Diffstat (limited to 'grammar')
-rw-r--r--grammar/rainerscript.c41
-rw-r--r--grammar/rainerscript.h6
2 files changed, 46 insertions, 1 deletions
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(&paramvals[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);