From: Sebastien GODARD Date: Sat, 26 Sep 2020 07:24:28 +0000 (+0200) Subject: sadc: Don't reallocate structures if buffers are large enough X-Git-Tag: v12.5.1~19 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=45c97501ca2877a1c2c929a8c5443834612d7bd3;p=sysstat sadc: Don't reallocate structures if buffers are large enough When appending data to an existing file, don't reallocate buffers if they are already large enough. Signed-off-by: Sebastien GODARD --- diff --git a/sadc.c b/sadc.c index 43ce549..7db7e93 100644 --- a/sadc.c +++ b/sadc.c @@ -996,9 +996,11 @@ void open_ofile(int *ofd, char ofile[], int restart_mark) * we need to reallocate. */ act[p]->nr2 = file_act[i].nr2; + if (act[p]->nr_ini > act[p]->nr_allocated) { + act[p]->nr_allocated = act[p]->nr_ini; + } SREALLOC(act[p]->_buf0, void, - (size_t) act[p]->msize * (size_t) act[p]->nr_ini * (size_t) act[p]->nr2); - act[p]->nr_allocated = act[p]->nr_ini; + (size_t) act[p]->msize * (size_t) act[p]->nr_allocated * (size_t) act[p]->nr2); /* Save activity sequence */ id_seq[i] = file_act[i].id;