diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2008-02-12 10:55:57 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2008-02-12 10:55:57 +0000 |
commit | 4e535179edb6e7b941276c451f6315c46dbda54a (patch) | |
tree | d3f51de62c9a223a7da13209b22a07432fdecf54 | |
parent | a2ae345e1851c4719ba99da46498f3fc120f2e95 (diff) | |
download | rsyslog-4e535179edb6e7b941276c451f6315c46dbda54a.tar.gz rsyslog-4e535179edb6e7b941276c451f6315c46dbda54a.tar.xz rsyslog-4e535179edb6e7b941276c451f6315c46dbda54a.zip |
somewhat improved performance of rsCStr obj
-rw-r--r-- | ChangeLog | 5 | ||||
-rwxr-xr-x | stringbuf.c | 29 | ||||
-rwxr-xr-x | stringbuf.h | 8 |
3 files changed, 25 insertions, 17 deletions
@@ -9,6 +9,11 @@ Version 3.11.1 (rgerhards), 2008-02-?? they run rsyslog ;)) - bugfix: trailing ":" of tag was lost while parsing legacy syslog messages without timestamp - thanks to Anders Blomdell for providing a patch! +- fixed a bug in stringbuf.c related to STRINGBUF_TRIM_ALLOCSIZE, which + wasn't supposed to be used with rsyslog. Put a warning message up that + tells this feature is not tested and probably not worth the effort. + Thanks to Anders Blomdell fro bringing this to our attention +- somewhat improved performance of string buffers --------------------------------------------------------------------------- Version 3.11.0 (rgerhards), 2008-01-31 - implemented queued actions 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) diff --git a/stringbuf.h b/stringbuf.h index 59f6e2fc..4649758a 100755 --- a/stringbuf.h +++ b/stringbuf.h @@ -147,6 +147,14 @@ int rsCStrSzStrMatchRegex(rsCStrObj *pCS1, uchar *psz); int rsCStrLen(rsCStrObj *pThis);
#endif
+#if STRINGBUF_TRIM_ALLOCSIZE != 1
+/* This is the normal case (see comment in rsCStrFinish!). In those cases, the function
+ * simply needs to do nothing, so that we can save us the function call.
+ * rgerhards, 2008-02-12
+ */
+#define rsCStrFinish(pThis) RS_RET_OK
+#endif
+
#define rsCStrGetBufBeg(x) ((x)->pBuf)
#endif /* single include */
|