From ac0a67eba13421d17b4f23b5bfeea456c8c39265 Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Wed, 9 Jan 2019 08:21:48 +0100 Subject: [PATCH] move adding 1 to meminit to the right place (needed only once) --- src/frontend/outitf.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/frontend/outitf.c b/src/frontend/outitf.c index 4222a8d20..2f470d273 100644 --- a/src/frontend/outitf.c +++ b/src/frontend/outitf.c @@ -426,13 +426,10 @@ addDataDesc(runDesc *run, char *name, int type, int ind, int meminit) { dataDesc *data; - - /* even if 0 input */ - meminit++; - - /* initialize memory (all or given by 'save' */ + /* initialize memory (for all vectors or given by 'save') */ if (!run->numData) { - run->data = TMALLOC(dataDesc, meminit); + /* even if input 0, do a malloc */ + run->data = TMALLOC(dataDesc, ++meminit); run->maxData = meminit; } /* If there is need for more memory */ @@ -441,7 +438,6 @@ addDataDesc(runDesc *run, char *name, int type, int ind, int meminit) run->data = TREALLOC(dataDesc, run->data, run->maxData); } - data = &run->data[run->numData]; /* so freeRun will get nice NULL pointers for the fields we don't set */ memset(data, 0, sizeof(dataDesc)); @@ -461,7 +457,7 @@ addDataDesc(runDesc *run, char *name, int type, int ind, int meminit) return (OK); } -/* Initialze memory for the list of all vectors in the currnt plot. +/* Initialze memory for the list of all vectors in the current plot. Add a special vector (e.g. @q1[ib]) to this plot */ static int addSpecialDesc(runDesc *run, char *name, char *devname, char *param, int depind, int meminit) @@ -470,11 +466,9 @@ addSpecialDesc(runDesc *run, char *name, char *devname, char *param, int depind, char *unique, *freeunique; /* unique char * from back-end */ int ret; - /* even if 0 input */ - meminit++; - if (!run->numData) { - run->data = TMALLOC(dataDesc, meminit); + /* even if input 0, do a malloc */ + run->data = TMALLOC(dataDesc, ++meminit); run->maxData = meminit; } else if (run->numData == run->maxData) {