diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2013-11-06 18:07:26 +0100 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2013-11-06 18:07:26 +0100 |
commit | e3dc6041424a779ddce3da8d55af9bc71c99aa61 (patch) | |
tree | 6dfbefb21141e300e56315b08fcd73c9d29a7b23 /runtime/wti.h | |
parent | 7253a2aa3f1644119222cb8b5d51c36774982705 (diff) | |
download | rsyslog-e3dc6041424a779ddce3da8d55af9bc71c99aa61.tar.gz rsyslog-e3dc6041424a779ddce3da8d55af9bc71c99aa61.tar.bz2 rsyslog-e3dc6041424a779ddce3da8d55af9bc71c99aa61.zip |
refactor iparams to use array
this is also prep work for a single doTransaction() output mode api
Diffstat (limited to 'runtime/wti.h')
-rw-r--r-- | runtime/wti.h | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/runtime/wti.h b/runtime/wti.h index 57c2bfea..9ac61c2d 100644 --- a/runtime/wti.h +++ b/runtime/wti.h @@ -44,7 +44,6 @@ * as well. -- gerhards, 2013-11-04 */ typedef struct actWrkrIParams { - struct actWrkrIParams *next; int msgFlags; /* following are caches to save allocs if not absolutely necessary */ uchar *staticActStrings[CONF_OMOD_NUMSTRINGS_MAXSIZE]; /**< for strings */ @@ -62,8 +61,9 @@ typedef struct actWrkrInfo { struct { unsigned actState : 3; } flags; - actWrkrIParams_t *iparamRoot; - actWrkrIParams_t *iparamLast; + actWrkrIParams_t *iparams; + int currIParam; + int maxIParams; /* current max */ void *staticActParams[CONF_OMOD_NUMSTRINGS_MAXSIZE]; /* for non-strings */ } actWrkrInfo_t; @@ -164,18 +164,23 @@ wtiNewIParam(wti_t *pWti, action_t *pAction, actWrkrIParams_t **piparams) { actWrkrInfo_t *wrkrInfo; actWrkrIParams_t *iparams; + int newMax; DEFiRet; wrkrInfo = &(pWti->actWrkrInfo[pAction->iActionNbr]); -dbgprintf("DDDD: adding param for action %d\n", pAction->iActionNbr); - CHKmalloc(iparams = calloc(1, sizeof(actWrkrIParams_t))); - if(wrkrInfo->iparamLast == NULL) { - wrkrInfo->iparamLast = wrkrInfo->iparamRoot = iparams; - } else { - wrkrInfo->iparamLast->next = iparams; - wrkrInfo->iparamLast = iparams; + if(wrkrInfo->currIParam == wrkrInfo->maxIParams) { + /* we need to extend */ + dbgprintf("DDDD: extending iparams, max %d\n", wrkrInfo->maxIParams); + newMax = (wrkrInfo->maxIParams == 0) ? CONF_IPARAMS_BUFSIZE : 2 * wrkrInfo->maxIParams; + CHKmalloc(iparams = realloc(wrkrInfo->iparams, sizeof(actWrkrIParams_t) * newMax)); + wrkrInfo->iparams = iparams; + wrkrInfo->maxIParams = newMax; } +dbgprintf("DDDD: adding param %d for action %d\n", wrkrInfo->currIParam, pAction->iActionNbr); + iparams = wrkrInfo->iparams + wrkrInfo->currIParam; + memset(iparams, 0, sizeof(actWrkrIParams_t)); *piparams = iparams; + ++wrkrInfo->currIParam; finalize_it: RETiRet; |