com_write(), com_write_sparam(), fix a big memory leak

This commit is contained in:
rlar 2012-10-15 20:55:55 +02:00
parent c6e631f30a
commit 31fa48cf17
1 changed files with 20 additions and 2 deletions

View File

@ -434,11 +434,13 @@ com_write(wordlist *wl)
*/
for (d = vecs; d; d = d->v_link2) {
if (d->v_plot == tpl) {
char *basename = vec_basename(d);
vv = vec_copy(d);
/* Note that since we are building a new plot
* we don't want to vec_new this one...
*/
vv->v_name = vec_basename(vv);
tfree(vv->v_name);
vv->v_name = basename;
if (end)
end->v_next = vv;
@ -491,6 +493,13 @@ com_write(wordlist *wl)
else
raw_write(file, &newplot, appendwrite, TRUE);
for (vv = newplot.pl_dvecs; vv;) {
struct dvec *next_vv = vv->v_next;
vv->v_plot = NULL;
vec_free(vv);
vv = next_vv;
}
/* Now throw out the vectors we have written already... */
for (d = vecs, lv = NULL; d; d = d->v_link2)
if (d->v_plot == tpl) {
@ -589,11 +598,13 @@ com_write_sparam(wordlist *wl)
*/
for (d = vecs; d; d = d->v_link2) {
if (d->v_plot == tpl) {
char *basename = vec_basename(d);
vv = vec_copy(d);
/* Note that since we are building a new plot
* we don't want to vec_new this one...
*/
vv->v_name = vec_basename(vv);
tfree(vv->v_name);
vv->v_name = basename;
if (end)
end->v_next = vv;
@ -642,6 +653,13 @@ com_write_sparam(wordlist *wl)
spar_write(file, &newplot, Rbaseval);
for (vv = newplot.pl_dvecs; vv;) {
struct dvec *next_vv = vv->v_next;
vv->v_plot = NULL;
vec_free(vv);
vv = next_vv;
}
/* Now throw out the vectors we have written already... */
for (d = vecs, lv = NULL; d; d = d->v_link2)
if (d->v_plot == tpl) {