diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2008-02-20 14:02:33 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2008-02-20 14:02:33 +0000 |
commit | c6bebca3c76985016970d87e75dd025a169790b0 (patch) | |
tree | 1d429d1c82e9775de8dcf746dd5b4720d1c1fce6 | |
parent | 33f061484d7456f0eb34f9ebab7a82e25ac26448 (diff) | |
download | rsyslog-c6bebca3c76985016970d87e75dd025a169790b0.tar.gz rsyslog-c6bebca3c76985016970d87e75dd025a169790b0.tar.xz rsyslog-c6bebca3c76985016970d87e75dd025a169790b0.zip |
changed rsCStrDestruct() to use the new interface conventions
-rw-r--r-- | cfsysline.c | 4 | ||||
-rw-r--r-- | conf.c | 2 | ||||
-rw-r--r-- | ctok.c | 6 | ||||
-rw-r--r-- | ctok_token.c | 2 | ||||
-rw-r--r-- | msg.c | 13 | ||||
-rw-r--r-- | obj.c | 2 | ||||
-rw-r--r-- | parse.c | 22 | ||||
-rw-r--r-- | stream.c | 2 | ||||
-rwxr-xr-x | stringbuf.c | 8 | ||||
-rwxr-xr-x | stringbuf.h | 2 | ||||
-rw-r--r-- | syslogd.c | 14 | ||||
-rw-r--r-- | template.c | 10 |
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; } @@ -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); @@ -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) @@ -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; } @@ -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; } @@ -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; } @@ -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
@@ -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 */ @@ -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; |