summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-02-20 14:02:33 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2008-02-20 14:02:33 +0000
commitc6bebca3c76985016970d87e75dd025a169790b0 (patch)
tree1d429d1c82e9775de8dcf746dd5b4720d1c1fce6
parent33f061484d7456f0eb34f9ebab7a82e25ac26448 (diff)
downloadrsyslog-c6bebca3c76985016970d87e75dd025a169790b0.tar.gz
rsyslog-c6bebca3c76985016970d87e75dd025a169790b0.tar.xz
rsyslog-c6bebca3c76985016970d87e75dd025a169790b0.zip
changed rsCStrDestruct() to use the new interface conventions
-rw-r--r--cfsysline.c4
-rw-r--r--conf.c2
-rw-r--r--ctok.c6
-rw-r--r--ctok_token.c2
-rw-r--r--msg.c13
-rw-r--r--obj.c2
-rw-r--r--parse.c22
-rw-r--r--stream.c2
-rwxr-xr-xstringbuf.c8
-rwxr-xr-xstringbuf.h2
-rw-r--r--syslogd.c14
-rw-r--r--template.c10
12 files changed, 44 insertions, 43 deletions
diff --git a/cfsysline.c b/cfsysline.c
index 378bfe1d..27a3efd3 100644
--- a/cfsysline.c
+++ b/cfsysline.c
@@ -512,7 +512,7 @@ static rsRetVal doGetWord(uchar **pp, rsRetVal (*pSetHdlr)(void*, uchar*), void
finalize_it:
if(iRet != RS_RET_OK) {
if(pStrB != NULL)
- rsCStrDestruct(pStrB);
+ rsCStrDestruct(&pStrB);
}
RETiRet;
@@ -549,7 +549,7 @@ doSyslogName(uchar **pp, rsRetVal (*pSetHdlr)(void*, int), void *pVal, syslogNam
finalize_it:
if(pStrB != NULL)
- rsCStrDestruct(pStrB);
+ rsCStrDestruct(&pStrB);
RETiRet;
}
diff --git a/conf.c b/conf.c
index fbf3e224..f1a996c7 100644
--- a/conf.c
+++ b/conf.c
@@ -856,7 +856,7 @@ static rsRetVal cflineProcessPropFilter(uchar **pline, register selector_t *f)
logerrorSz("error: invalid compare operation '%s' - ignoring selector",
(char*) rsCStrGetSzStrNoNULL(pCSCompOp));
}
- rsCStrDestruct (pCSCompOp); /* no longer needed */
+ rsCStrDestruct(&pCSCompOp); /* no longer needed */
/* read compare value */
iRet = parsQuotedCStr(pPars, &f->f_filterData.prop.pCSCompValue);
diff --git a/ctok.c b/ctok.c
index 716fdefc..3d0b55f7 100644
--- a/ctok.c
+++ b/ctok.c
@@ -266,8 +266,7 @@ dbgprintf("var, var is: '%s'\n", rsCStrGetSzStr(pToken->pstrVal));
finalize_it:
if(iRet != RS_RET_OK) {
if(pToken->pstrVal != NULL) {
- rsCStrDestruct(pToken->pstrVal);
- pToken->pstrVal = NULL;
+ rsCStrDestruct(&pToken->pstrVal);
}
}
@@ -315,8 +314,7 @@ dbgprintf("simpstr, str is: '%s'\n", rsCStrGetSzStr(pToken->pstrVal));
finalize_it:
if(iRet != RS_RET_OK) {
if(pToken->pstrVal != NULL) {
- rsCStrDestruct(pToken->pstrVal);
- pToken->pstrVal = NULL;
+ rsCStrDestruct(&pToken->pstrVal);
}
}
diff --git a/ctok_token.c b/ctok_token.c
index a8bd9d97..7e768f37 100644
--- a/ctok_token.c
+++ b/ctok_token.c
@@ -56,7 +56,7 @@ rsRetVal ctok_tokenConstructFinalize(ctok_token_t __attribute__((unused)) *pThis
BEGINobjDestruct(ctok_token) /* be sure to specify the object type also in END and CODESTART macros! */
CODESTARTobjDestruct(ctok_token)
if(pThis->pstrVal != NULL) {
- rsCStrDestruct(pThis->pstrVal);
+ rsCStrDestruct(&pThis->pstrVal);
}
ENDobjDestruct(ctok_token)
diff --git a/msg.c b/msg.c
index b23d2724..505f878a 100644
--- a/msg.c
+++ b/msg.c
@@ -274,15 +274,15 @@ CODESTARTobjDestruct(msg)
if(pThis->pszPRI != NULL)
free(pThis->pszPRI);
if(pThis->pCSProgName != NULL)
- rsCStrDestruct(pThis->pCSProgName);
+ rsCStrDestruct(&pThis->pCSProgName);
if(pThis->pCSStrucData != NULL)
- rsCStrDestruct(pThis->pCSStrucData);
+ rsCStrDestruct(&pThis->pCSStrucData);
if(pThis->pCSAPPNAME != NULL)
- rsCStrDestruct(pThis->pCSAPPNAME);
+ rsCStrDestruct(&pThis->pCSAPPNAME);
if(pThis->pCSPROCID != NULL)
- rsCStrDestruct(pThis->pCSPROCID);
+ rsCStrDestruct(&pThis->pCSPROCID);
if(pThis->pCSMSGID != NULL)
- rsCStrDestruct(pThis->pCSMSGID);
+ rsCStrDestruct(&pThis->pCSMSGID);
funcDeleteMutex(pThis);
} else {
pThis = NULL; /* tell framework not to destructing the object! */
@@ -480,8 +480,7 @@ static rsRetVal aquirePROCIDFromTAG(msg_t *pM)
* the buffer and simply return. Note that this is NOT an error
* case!
*/
- rsCStrDestruct(pM->pCSPROCID);
- pM->pCSPROCID = NULL;
+ rsCStrDestruct(&pM->pCSPROCID);
FINALIZE;
}
diff --git a/obj.c b/obj.c
index 6edddbac..093fa008 100644
--- a/obj.c
+++ b/obj.c
@@ -381,7 +381,7 @@ static rsRetVal objDeserializeStr(rsCStrObj **ppCStr, int iLen, strm_t *pStrm)
finalize_it:
if(iRet != RS_RET_OK && pCStr != NULL)
- rsCStrDestruct(pCStr);
+ rsCStrDestruct(&pCStr);
RETiRet;
}
diff --git a/parse.c b/parse.c
index b7edba98..75843286 100644
--- a/parse.c
+++ b/parse.c
@@ -58,7 +58,7 @@ rsRetVal rsParsDestruct(rsParsObj *pThis)
rsCHECKVALIDOBJECT(pThis, OIDrsPars);
if(pThis->pCStr != NULL)
- rsCStrDestruct (pThis->pCStr);
+ rsCStrDestruct(&pThis->pCStr);
RSFREEOBJ(pThis);
return RS_RET_OK;
}
@@ -101,7 +101,7 @@ rsRetVal rsParsConstructFromSz(rsParsObj **ppThis, unsigned char *psz)
/* create parser */
if((iRet = rsParsConstruct(&pThis)) != RS_RET_OK) {
- rsCStrDestruct (pCS);
+ rsCStrDestruct(&pCS);
FINALIZE;
}
@@ -257,7 +257,7 @@ rsRetVal parsDelimCStr(rsParsObj *pThis, rsCStrObj **ppCStr, char cDelim, int bT
while(pThis->iCurrPos < rsCStrLen(pThis->pCStr)
&& *pC != cDelim) {
if((iRet = rsCStrAppendChar(pCStr, *pC)) != RS_RET_OK) {
- rsCStrDestruct (pCStr);
+ rsCStrDestruct(&pCStr);
FINALIZE;
}
++pThis->iCurrPos;
@@ -272,14 +272,14 @@ rsRetVal parsDelimCStr(rsParsObj *pThis, rsCStrObj **ppCStr, char cDelim, int bT
* remove anything at its end.
*/
if((iRet = rsCStrFinish(pCStr)) != RS_RET_OK) {
- rsCStrDestruct (pCStr);
+ rsCStrDestruct (&pCStr);
FINALIZE;
}
if(bTrimTrailing) {
if((iRet = rsCStrTrimTrailingWhiteSpace(pCStr))
!= RS_RET_OK) {
- rsCStrDestruct (pCStr);
+ rsCStrDestruct (&pCStr);
FINALIZE;
}
}
@@ -332,13 +332,13 @@ rsRetVal parsQuotedCStr(rsParsObj *pThis, rsCStrObj **ppCStr)
* we might later introduce other things, like \007!
*/
if((iRet = rsCStrAppendChar(pCStr, *pC)) != RS_RET_OK) {
- rsCStrDestruct (pCStr);
+ rsCStrDestruct(&pCStr);
FINALIZE;
}
}
} else { /* regular character */
if((iRet = rsCStrAppendChar(pCStr, *pC)) != RS_RET_OK) {
- rsCStrDestruct (pCStr);
+ rsCStrDestruct (&pCStr);
FINALIZE;
}
}
@@ -350,13 +350,13 @@ rsRetVal parsQuotedCStr(rsParsObj *pThis, rsCStrObj **ppCStr)
++pThis->iCurrPos; /* 'eat' trailing quote */
} else {
/* error - improperly quoted string! */
- rsCStrDestruct (pCStr);
+ rsCStrDestruct (&pCStr);
ABORT_FINALIZE(RS_RET_MISSING_TRAIL_QUOTE);
}
/* We got the string, let's finish it... */
if((iRet = rsCStrFinish(pCStr)) != RS_RET_OK) {
- rsCStrDestruct (pCStr);
+ rsCStrDestruct (&pCStr);
FINALIZE;
}
@@ -399,7 +399,7 @@ rsRetVal parsAddrWithBits(rsParsObj *pThis, struct NetAddr **pIP, int *pBits)
while(pThis->iCurrPos < rsCStrLen(pThis->pCStr)
&& *pC != '/' && *pC != ',' && !isspace((int)*pC)) {
if((iRet = rsCStrAppendChar(pCStr, *pC)) != RS_RET_OK) {
- rsCStrDestruct (pCStr);
+ rsCStrDestruct (&pCStr);
FINALIZE;
}
++pThis->iCurrPos;
@@ -408,7 +408,7 @@ rsRetVal parsAddrWithBits(rsParsObj *pThis, struct NetAddr **pIP, int *pBits)
/* We got the string, let's finish it... */
if((iRet = rsCStrFinish(pCStr)) != RS_RET_OK) {
- rsCStrDestruct (pCStr);
+ rsCStrDestruct (&pCStr);
FINALIZE;
}
diff --git a/stream.c b/stream.c
index 24d42d17..95506685 100644
--- a/stream.c
+++ b/stream.c
@@ -370,7 +370,7 @@ strmReadLine(strm_t *pThis, rsCStrObj **ppCStr)
finalize_it:
if(iRet != RS_RET_OK && pCStr != NULL)
- rsCStrDestruct(pCStr);
+ rsCStrDestruct(&pCStr);
RETiRet;
}
diff --git a/stringbuf.c b/stringbuf.c
index 237355c0..3e222a5f 100755
--- a/stringbuf.c
+++ b/stringbuf.c
@@ -129,14 +129,19 @@ finalize_it:
}
-void rsCStrDestruct(rsCStrObj *pThis)
+void rsCStrDestruct(rsCStrObj **ppThis)
{
+ rsCStrObj *pThis = *ppThis;
+
/* rgerhards 2005-10-19: The free of pBuf was contained in conditional compilation.
* The code was only compiled if STRINGBUF_TRIM_ALLOCSIZE was set to 1. I honestly
* do not know why it was so, I think it was an artifact. Anyhow, I have changed this
* now. Should there any issue occur, this comment hopefully will shed some light
* on what happened. I re-verified, and this function has never before been called
* by anyone. So changing it can have no impact for obvious reasons...
+ *
+ * rgerhards, 2008-02-20: I changed the interface to the new calling conventions, where
+ * the destructor receives a pointer to the object, so that it can set it to NULL.
*/
if(pThis->pBuf != NULL) {
free(pThis->pBuf);
@@ -147,6 +152,7 @@ void rsCStrDestruct(rsCStrObj *pThis)
}
RSFREEOBJ(pThis);
+ *ppThis = NULL;
}
diff --git a/stringbuf.h b/stringbuf.h
index 123f59d7..779e05eb 100755
--- a/stringbuf.h
+++ b/stringbuf.h
@@ -62,7 +62,7 @@ rsRetVal rsCStrConstructFromCStr(rsCStrObj **ppThis, rsCStrObj *pFrom);
/**
* Destruct the string buffer object.
*/
-void rsCStrDestruct(rsCStrObj *pThis);
+void rsCStrDestruct(rsCStrObj **ppThis);
/**
* Append a character to an existing string. If necessary, the
diff --git a/syslogd.c b/syslogd.c
index 3550de7e..4a5f5502 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -989,15 +989,15 @@ selectorDestruct(void *pVal)
assert(pThis != NULL);
if(pThis->pCSHostnameComp != NULL)
- rsCStrDestruct(pThis->pCSHostnameComp);
+ rsCStrDestruct(&pThis->pCSHostnameComp);
if(pThis->pCSProgNameComp != NULL)
- rsCStrDestruct(pThis->pCSProgNameComp);
+ rsCStrDestruct(&pThis->pCSProgNameComp);
if(pThis->f_filter_type == FILTER_PROP) {
if(pThis->f_filterData.prop.pCSPropName != NULL)
- rsCStrDestruct(pThis->f_filterData.prop.pCSPropName);
+ rsCStrDestruct(&pThis->f_filterData.prop.pCSPropName);
if(pThis->f_filterData.prop.pCSCompValue != NULL)
- rsCStrDestruct(pThis->f_filterData.prop.pCSCompValue);
+ rsCStrDestruct(&pThis->f_filterData.prop.pCSCompValue);
} else if(pThis->f_filter_type == FILTER_EXPR) {
if(pThis->f_filterData.f_expr != NULL)
exprDestruct(&pThis->f_filterData.f_expr);
@@ -2697,13 +2697,11 @@ init(void)
* free some objects that were just needed for loading it. rgerhards 2005-10-19
*/
if(pDfltHostnameCmp != NULL) {
- rsCStrDestruct(pDfltHostnameCmp);
- pDfltHostnameCmp = NULL;
+ rsCStrDestruct(&pDfltHostnameCmp);
}
if(pDfltProgNameCmp != NULL) {
- rsCStrDestruct(pDfltProgNameCmp);
- pDfltProgNameCmp = NULL;
+ rsCStrDestruct(&pDfltProgNameCmp);
}
/* some checks */
diff --git a/template.c b/template.c
index 9a5a2651..36cc30a3 100644
--- a/template.c
+++ b/template.c
@@ -89,7 +89,7 @@ rsRetVal tplToString(struct template *pTpl, msg_t *pMsg, uchar** ppSz)
) {
dbgprintf("error %d during tplToString()\n", iRet);
/* it does not make sense to continue now */
- rsCStrDestruct(pCStr);
+ rsCStrDestruct(&pCStr);
FINALIZE;
}
} else if(pTpe->eEntryType == FIELD) {
@@ -109,7 +109,7 @@ rsRetVal tplToString(struct template *pTpl, msg_t *pMsg, uchar** ppSz)
CHKiRet_Hdlr(rsCStrAppendStrWithLen(pCStr, (uchar*) pVal, iLenVal)) {
dbgprintf("error %d during tplToString()\n", iRet);
/* it does not make sense to continue now */
- rsCStrDestruct(pCStr);
+ rsCStrDestruct(&pCStr);
if(bMustBeFreed)
free(pVal);
FINALIZE;
@@ -216,21 +216,21 @@ void doSQLEscape(uchar **pp, size_t *pLen, unsigned short *pbMustBeFreed, int es
if(*p == '\'') {
if(rsCStrAppendChar(pStrB, (escapeMode == 0) ? '\'' : '\\') != RS_RET_OK) {
doSQLEmergencyEscape(*pp, escapeMode);
- rsCStrDestruct(pStrB);
+ rsCStrDestruct(&pStrB);
return;
}
iLen++; /* reflect the extra character */
} else if((escapeMode == 1) && (*p == '\\')) {
if(rsCStrAppendChar(pStrB, '\\') != RS_RET_OK) {
doSQLEmergencyEscape(*pp, escapeMode);
- rsCStrDestruct(pStrB);
+ rsCStrDestruct(&pStrB);
return;
}
iLen++; /* reflect the extra character */
}
if(rsCStrAppendChar(pStrB, *p) != RS_RET_OK) {
doSQLEmergencyEscape(*pp, escapeMode);
- rsCStrDestruct(pStrB);
+ rsCStrDestruct(&pStrB);
return;
}
++p;