From 2d1c46db8fa1085d43fd068d8f45fcc76d323b36 Mon Sep 17 00:00:00 2001 From: h_vogt Date: Mon, 13 Jun 2016 20:53:26 +0200 Subject: [PATCH] postcoms.c, remove leak by deleting hash table of variables if 'destroy' is executed. Add deleting pl->pl_env. --- src/frontend/postcoms.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/frontend/postcoms.c b/src/frontend/postcoms.c index 138d69dec..8f9f40193 100644 --- a/src/frontend/postcoms.c +++ b/src/frontend/postcoms.c @@ -867,19 +867,20 @@ killplot(struct plot *pl) tfree(pl->pl_name); tfree(pl->pl_typename); wl_free(pl->pl_commands); - tfree(pl->pl_date); /* va: also tfree (memory leak) */ - if (pl->pl_ccom) /* va: also tfree (memory leak) */ + tfree(pl->pl_date); + if (pl->pl_ccom) 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); - } - tfree(pl); /* va: also tfree pl itself (memory leak) */ + if (pl->pl_env) + free_struct_variable(pl->pl_env); + if (pl->pl_lookup_table) + nghash_free(pl->pl_lookup_table, NULL, NULL); + tfree(pl); } +/* shared ngspice: remove plot 'const' upon 'quit' + constanplot is not dynamically allocated on the heap */ void destroy_const_plot(void) { @@ -892,14 +893,13 @@ destroy_const_plot(void) vec_free(v); } wl_free(pl->pl_commands); - if (pl->pl_ccom) /* va: also tfree (memory leak) */ + if (pl->pl_ccom) 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); - } + if (pl->pl_env) + free_struct_variable(pl->pl_env); + if (pl->pl_lookup_table) + nghash_free(pl->pl_lookup_table, NULL, NULL); }