diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2009-06-22 18:52:30 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2009-06-22 18:52:30 +0200 |
commit | ce5869f7c41c8db943d8cbe804b69af40d43e2e6 (patch) | |
tree | 5e36c1e35728021f6b067d668bf71245202e90a5 /runtime/msg.c | |
parent | 221dc8a3224dcb59a7dd3158716a8d24cee71618 (diff) | |
download | rsyslog-ce5869f7c41c8db943d8cbe804b69af40d43e2e6.tar.gz rsyslog-ce5869f7c41c8db943d8cbe804b69af40d43e2e6.tar.xz rsyslog-ce5869f7c41c8db943d8cbe804b69af40d43e2e6.zip |
optimized processing of TAG message field
Diffstat (limited to 'runtime/msg.c')
-rw-r--r-- | runtime/msg.c | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/runtime/msg.c b/runtime/msg.c index 2ff63d9c..1a864648 100644 --- a/runtime/msg.c +++ b/runtime/msg.c @@ -1303,19 +1303,6 @@ static inline char *getMSGID(msg_t *pM) } -/* Set the TAG to a caller-provided string. This is thought - * to be a heap buffer that the caller will no longer use. This - * function is a performance optimization over MsgSetTAG(). - * rgerhards 2004-11-19 - */ -void MsgAssignTAG(msg_t *pMsg, uchar *pBuf) -{ - assert(pMsg != NULL); - MsgSetTAG(pMsg, pBuf, ustrlen(pBuf)); - free(pBuf); -} - - /* rgerhards 2009-06-12: set associated ruleset */ void MsgSetRuleset(msg_t *pMsg, ruleset_t *pRuleset) @@ -1361,10 +1348,10 @@ void MsgSetTAG(msg_t *pMsg, uchar* pszBuf, size_t lenBuf) * if there is a TAG and, if not, if it can emulate it. * rgerhards, 2005-11-24 */ -static void tryEmulateTAG(msg_t *pM) +static inline void tryEmulateTAG(msg_t *pM) { - int iTAGLen; - uchar *pBuf; + size_t lenTAG; + uchar bufTAG[CONF_TAG_MAXSIZE]; assert(pM != NULL); if(pM->iLenTAG > 0) @@ -1376,11 +1363,9 @@ static void tryEmulateTAG(msg_t *pM) MsgSetTAG(pM, (uchar*) getAPPNAME(pM), getAPPNAMELen(pM)); } else { /* now we can try to emulate */ - iTAGLen = getAPPNAMELen(pM) + getPROCIDLen(pM) + 3; - if((pBuf = malloc(iTAGLen * sizeof(char))) == NULL) - return; /* nothing we can do */ - snprintf((char*)pBuf, iTAGLen, "%s[%s]", getAPPNAME(pM), getPROCID(pM)); - MsgAssignTAG(pM, pBuf); + lenTAG = snprintf((char*)bufTAG, CONF_TAG_MAXSIZE, "%s[%s]", getAPPNAME(pM), getPROCID(pM)); + bufTAG[32] = '\0'; /* just to make sure... */ + MsgSetTAG(pM, bufTAG, lenTAG); } } } |