From 811bf5664a4d5a46b7734bfeab4379ecc357acef Mon Sep 17 00:00:00 2001 From: rlar Date: Fri, 21 Sep 2012 21:15:41 +0200 Subject: [PATCH] destroy `const' plot in com_quit() --- src/frontend/misccoms.c | 1 + src/frontend/postcoms.c | 24 ++++++++++++++++++++++++ src/frontend/postcoms.h | 2 ++ 3 files changed, 27 insertions(+) diff --git a/src/frontend/misccoms.c b/src/frontend/misccoms.c index 7454b279b..e0e412a65 100644 --- a/src/frontend/misccoms.c +++ b/src/frontend/misccoms.c @@ -79,6 +79,7 @@ com_quit(wordlist *wl) destroy_ivars(); byemesg(); + destroy_const_plot(); exit(exitcode); } diff --git a/src/frontend/postcoms.c b/src/frontend/postcoms.c index 7dc45b296..6a5c839c9 100644 --- a/src/frontend/postcoms.c +++ b/src/frontend/postcoms.c @@ -22,6 +22,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "quote.h" #include "variable.h" #include "parser/complete.h" /* va: throwaway */ +#include "plotting/plotting.h" static void killplot(struct plot *pl); @@ -856,6 +857,29 @@ killplot(struct plot *pl) } +void +destroy_const_plot(void) +{ + struct dvec *v, *nv = NULL; + struct plot *pl = &constantplot; + + /* pl_dvecs, pl_scale */ + for (v = pl->pl_dvecs; v; v = nv) { + nv = v->v_next; + vec_free(v); + } + wl_free(pl->pl_commands); + if (pl->pl_ccom) /* va: also tfree (memory leak) */ + throwaway(pl->pl_ccom); + + if (pl->pl_env) { /* The 'environment' for this plot. */ + /* va: HOW to do? */ + printf("va: killplot should tfree pl->pl_env=(%p)\n", pl->pl_env); + fflush(stdout); + } +} + + /* delete all windows with graphs dedrived from a given plot */ static void DelPlotWindows(struct plot *pl) diff --git a/src/frontend/postcoms.h b/src/frontend/postcoms.h index 105305b6c..e6ff112db 100644 --- a/src/frontend/postcoms.h +++ b/src/frontend/postcoms.h @@ -16,5 +16,7 @@ void com_cross(wordlist *wl); void com_destroy(wordlist *wl); void com_splot(wordlist *wl); +void destroy_const_plot(void); + #endif