summaryrefslogtreecommitdiffstats
path: root/runtime/batch.h
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2011-02-28 16:23:18 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2011-02-28 16:23:18 +0100
commitc0f92325c634fd3d0482f5d8bdc6650ab725cce1 (patch)
tree87073391e08087a17d2088b14523cdb63e57b524 /runtime/batch.h
parentbf088c5c2ed06db1c765a96df3762a00ae44db9c (diff)
parent74a71e798efd58e20cc150b04de2613bf518eed4 (diff)
downloadrsyslog-c0f92325c634fd3d0482f5d8bdc6650ab725cce1.tar.gz
rsyslog-c0f92325c634fd3d0482f5d8bdc6650ab725cce1.tar.xz
rsyslog-c0f92325c634fd3d0482f5d8bdc6650ab725cce1.zip
Merge branch 'master' into master-tcpsrv-mt
Diffstat (limited to 'runtime/batch.h')
-rw-r--r--runtime/batch.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/runtime/batch.h b/runtime/batch.h
index d0504f2b..944889bd 100644
--- a/runtime/batch.h
+++ b/runtime/batch.h
@@ -136,11 +136,16 @@ batchIsValidElem(batch_t *pBatch, int i) {
/* copy one batch element to another.
* This creates a complete duplicate in those cases where
* it is needed. Use duplication only when absolutely necessary!
+ * Note that all working fields are reset to zeros. If that were
+ * not done, we would have potential problems with invalid
+ * or double pointer frees.
* rgerhards, 2010-06-10
*/
static inline void
batchCopyElem(batch_obj_t *pDest, batch_obj_t *pSrc) {
- memcpy(pDest, pSrc, sizeof(batch_obj_t));
+ memset(pDest, 0, sizeof(batch_obj_t));
+ pDest->pUsrp = pSrc->pUsrp;
+ pDest->state = pSrc->state;
}
@@ -171,6 +176,7 @@ batchFree(batch_t *pBatch) {
static inline rsRetVal
batchInit(batch_t *pBatch, int maxElem) {
DEFiRet;
+ pBatch->iDoneUpTo = 0;
pBatch->maxElem = maxElem;
CHKmalloc(pBatch->pElem = calloc((size_t)maxElem, sizeof(batch_obj_t)));
// TODO: replace calloc by inidividual writes?