summaryrefslogtreecommitdiffstats
path: root/stringbuf.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-02-12 10:55:57 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2008-02-12 10:55:57 +0000
commit4e535179edb6e7b941276c451f6315c46dbda54a (patch)
treed3f51de62c9a223a7da13209b22a07432fdecf54 /stringbuf.c
parenta2ae345e1851c4719ba99da46498f3fc120f2e95 (diff)
downloadrsyslog-4e535179edb6e7b941276c451f6315c46dbda54a.tar.gz
rsyslog-4e535179edb6e7b941276c451f6315c46dbda54a.tar.xz
rsyslog-4e535179edb6e7b941276c451f6315c46dbda54a.zip
somewhat improved performance of rsCStr obj
Diffstat (limited to 'stringbuf.c')
-rwxr-xr-xstringbuf.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/stringbuf.c b/stringbuf.c
index ebc9b800..7f3575cf 100755
--- a/stringbuf.c
+++ b/stringbuf.c
@@ -425,15 +425,11 @@ finalize_it:
}
-rsRetVal rsCStrFinish(rsCStrObj __attribute__((unused)) *pThis)
-{
- DEFiRet;
-# if STRINGBUF_TRIM_ALLOCSIZE == 1
- uchar* pBuf;
-# endif
- rsCHECKVALIDOBJECT(pThis, OIDrsCStr);
-
-# if STRINGBUF_TRIM_ALLOCSIZE == 1
+#if STRINGBUF_TRIM_ALLOCSIZE == 1
+ /* Only in this mode, we need to trim the string. To do
+ * so, we must allocate a new buffer of the exact
+ * string size, and then copy the old one over.
+ */
/* WARNING
* STRINGBUF_TRIM_ALLOCSIZE can, in theory, be used to trim
* memory buffers. This part of the code was inherited from
@@ -448,11 +444,12 @@ rsRetVal rsCStrFinish(rsCStrObj __attribute__((unused)) *pThis)
* tested the fix. So if you intend to use this feature, you must
* do full testing before you rely on it. -- rgerhards, 2008-02-12
*/
+rsRetVal rsCStrFinish(rsCStrObj __attribute__((unused)) *pThis)
+{
+ DEFiRet;
+ uchar* pBuf;
+ rsCHECKVALIDOBJECT(pThis, OIDrsCStr);
- /* in this mode, we need to trim the string. To do
- * so, we must allocate a new buffer of the exact
- * string size, and then copy the old one over.
- */
if((pBuf = malloc((pThis->iStrLen) * sizeof(uchar))) == NULL)
{ /* OK, in this case we use the previous buffer. At least
* we have it ;)
@@ -463,12 +460,10 @@ rsRetVal rsCStrFinish(rsCStrObj __attribute__((unused)) *pThis)
memcpy(pBuf, pThis->pBuf, pThis->iStrLen);
pThis->pBuf = pBuf;
}
-# else
- /* here, we need to do ... nothing ;)
- */
-# endif
+
RETiRet;
}
+#endif /* #if STRINGBUF_TRIM_ALLOCSIZE == 1 */
void rsCStrSetAllocIncrement(rsCStrObj *pThis, int iNewIncrement)