summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2009-06-10 18:05:24 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2009-06-10 18:05:24 +0200
commit1dbdee7c774dd20e4653efc6871ddef5adce2785 (patch)
tree2a8ac42118550992e2e342a951330e2ffb5fa332 /runtime
parent0290be816e683a711fc3c3a73a2ec79b804cfc8b (diff)
downloadrsyslog-1dbdee7c774dd20e4653efc6871ddef5adce2785.tar.gz
rsyslog-1dbdee7c774dd20e4653efc6871ddef5adce2785.tar.xz
rsyslog-1dbdee7c774dd20e4653efc6871ddef5adce2785.zip
fixed a small memory leak...
and another problem, both introduced today. Also did some general cleanup.
Diffstat (limited to 'runtime')
-rw-r--r--runtime/obj.c39
-rw-r--r--runtime/rule.c3
-rw-r--r--runtime/wti.c3
-rw-r--r--runtime/wtp.c3
4 files changed, 18 insertions, 30 deletions
diff --git a/runtime/obj.c b/runtime/obj.c
index f5ec66b2..8b9c9c83 100644
--- a/runtime/obj.c
+++ b/runtime/obj.c
@@ -87,6 +87,7 @@
#include "modules.h"
#include "errmsg.h"
#include "cfsysline.h"
+#include "unicode-helper.h"
/* static data */
DEFobjCurrIf(obj) /* we define our own interface, as this is expected by some macros! */
@@ -145,8 +146,8 @@ InfoConstruct(objInfo_t **ppThis, uchar *pszID, int iObjVers,
ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY);
pThis->pszID = pszID;
- pThis->lenID = strlen((char*)pszID);
- pThis->pszName = (uchar*)strdup((char*)pszID); /* it's OK if we have NULL ptr, GetName() will deal with that! */
+ pThis->lenID = ustrlen(pszID);
+ pThis->pszName = ustrdup(pszID); /* it's OK if we have NULL ptr, GetName() will deal with that! */
pThis->iObjVers = iObjVers;
pThis->QueryIF = pQueryIF;
pThis->pModInfo = pModInfo;
@@ -177,8 +178,7 @@ InfoDestruct(objInfo_t **ppThis)
pThis = *ppThis;
assert(pThis != NULL);
- if(pThis->pszName != NULL)
- free(pThis->pszName);
+ free(pThis->pszName);
free(pThis);
*ppThis = NULL;
@@ -206,9 +206,7 @@ DestructObjSelf(obj_t *pThis)
DEFiRet;
ISOBJ_assert(pThis);
- if(pThis->pszName != NULL) {
- free(pThis->pszName);
- }
+ free(pThis->pszName);
RETiRet;
}
@@ -321,31 +319,31 @@ SerializeProp(strm_t *pStrm, uchar *pszPropName, propType_t propType, void *pUsr
switch(propType) {
case PROPTYPE_PSZ:
pszBuf = (uchar*) pUsr;
- lenBuf = strlen((char*) pszBuf);
+ lenBuf = ustrlen(pszBuf);
vType = VARTYPE_STR;
break;
case PROPTYPE_SHORT:
CHKiRet(srUtilItoA((char*) szBuf, sizeof(szBuf), (long) *((short*) pUsr)));
pszBuf = szBuf;
- lenBuf = strlen((char*) szBuf);
+ lenBuf = ustrlen(szBuf);
vType = VARTYPE_NUMBER;
break;
case PROPTYPE_INT:
CHKiRet(srUtilItoA((char*) szBuf, sizeof(szBuf), (long) *((int*) pUsr)));
pszBuf = szBuf;
- lenBuf = strlen((char*) szBuf);
+ lenBuf = ustrlen(szBuf);
vType = VARTYPE_NUMBER;
break;
case PROPTYPE_LONG:
CHKiRet(srUtilItoA((char*) szBuf, sizeof(szBuf), *((long*) pUsr)));
pszBuf = szBuf;
- lenBuf = strlen((char*) szBuf);
+ lenBuf = ustrlen(szBuf);
vType = VARTYPE_NUMBER;
break;
case PROPTYPE_INT64:
CHKiRet(srUtilItoA((char*) szBuf, sizeof(szBuf), *((int64*) pUsr)));
pszBuf = szBuf;
- lenBuf = strlen((char*) szBuf);
+ lenBuf = ustrlen(szBuf);
vType = VARTYPE_NUMBER;
break;
case PROPTYPE_CSTR:
@@ -380,7 +378,7 @@ SerializeProp(strm_t *pStrm, uchar *pszPropName, propType_t propType, void *pUsr
/* cookie */
CHKiRet(strm.WriteChar(pStrm, COOKIE_PROPLINE));
/* name */
- CHKiRet(strm.Write(pStrm, pszPropName, strlen((char*)pszPropName)));
+ CHKiRet(strm.Write(pStrm, pszPropName, ustrlen(pszPropName)));
CHKiRet(strm.WriteChar(pStrm, ':'));
/* type */
CHKiRet(strm.WriteLong(pStrm, (int) vType));
@@ -804,7 +802,7 @@ Deserialize(void *ppObj, uchar *pszTypeExpected, strm_t *pStrm, rsRetVal (*fFixu
}
} while(iRetLocal != RS_RET_OK);
- if(rsCStrSzStrCmp(pstrID, pszTypeExpected, strlen((char*)pszTypeExpected))) /* TODO: optimize strlen() - caller shall provide */
+ if(rsCStrSzStrCmp(pstrID, pszTypeExpected, ustrlen(pszTypeExpected))) /* TODO: optimize strlen() - caller shall provide */
ABORT_FINALIZE(RS_RET_INVALID_OID);
CHKiRet(FindObjInfo(pstrID, &pObjInfo));
@@ -949,13 +947,8 @@ SetName(obj_t *pThis, uchar *pszName)
{
DEFiRet;
- if(pThis->pszName != NULL)
- free(pThis->pszName);
-
- pThis->pszName = (uchar*) strdup((char*) pszName);
-
- if(pThis->pszName == NULL)
- ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY);
+ free(pThis->pszName);
+ CHKmalloc(pThis->pszName = ustrdup(pszName));
finalize_it:
RETiRet;
@@ -1058,7 +1051,7 @@ RegisterObj(uchar *pszObjName, objInfo_t *pInfo)
i = 0;
while(!bFound && i < OBJ_NUM_IDS && arrObjInfo[i] != NULL) {
if( arrObjInfo[i] != NULL
- && !strcmp((char*)arrObjInfo[i]->pszID, (char*)pszObjName)) {
+ && !ustrcmp(arrObjInfo[i]->pszID, pszObjName)) {
bFound = 1;
break;
}
@@ -1097,7 +1090,7 @@ UnregisterObj(uchar *pszObjName)
i = 0;
while(!bFound && i < OBJ_NUM_IDS) {
if( arrObjInfo[i] != NULL
- && !strcmp((char*)arrObjInfo[i]->pszID, (char*)pszObjName)) {
+ && !ustrcmp(arrObjInfo[i]->pszID, pszObjName)) {
bFound = 1;
break;
}
diff --git a/runtime/rule.c b/runtime/rule.c
index fa56dc3b..c157242c 100644
--- a/runtime/rule.c
+++ b/runtime/rule.c
@@ -317,9 +317,6 @@ CODESTARTobjDestruct(rule)
}
llDestroy(&pThis->llActList);
- free(pThis);
-
- return RS_RET_OK;
ENDobjDestruct(rule)
diff --git a/runtime/wti.c b/runtime/wti.c
index 544bffa7..18767ea1 100644
--- a/runtime/wti.c
+++ b/runtime/wti.c
@@ -201,8 +201,7 @@ CODESTARTobjDestruct(wti)
pthread_cond_destroy(&pThis->condExitDone);
pthread_mutex_destroy(&pThis->mut);
- if(pThis->pszDbgHdr != NULL)
- free(pThis->pszDbgHdr);
+ free(pThis->pszDbgHdr);
ENDobjDestruct(wti)
diff --git a/runtime/wtp.c b/runtime/wtp.c
index 04eb974f..df39daa3 100644
--- a/runtime/wtp.c
+++ b/runtime/wtp.c
@@ -151,8 +151,7 @@ CODESTARTobjDestruct(wtp)
pthread_mutex_destroy(&pThis->mut);
pthread_mutex_destroy(&pThis->mutThrdShutdwn);
- if(pThis->pszDbgHdr != NULL)
- free(pThis->pszDbgHdr);
+ free(pThis->pszDbgHdr);
ENDobjDestruct(wtp)