postcoms.c, remove leak by deleting hash table of variables if 'destroy' is executed. Add deleting pl->pl_env.

This commit is contained in:
h_vogt 2016-06-13 20:53:26 +02:00 committed by rlar
parent 06adfa3753
commit 2d1c46db8f
1 changed files with 14 additions and 14 deletions

View File

@ -867,19 +867,20 @@ killplot(struct plot *pl)
tfree(pl->pl_name); tfree(pl->pl_name);
tfree(pl->pl_typename); tfree(pl->pl_typename);
wl_free(pl->pl_commands); wl_free(pl->pl_commands);
tfree(pl->pl_date); /* va: also tfree (memory leak) */ tfree(pl->pl_date);
if (pl->pl_ccom) /* va: also tfree (memory leak) */ if (pl->pl_ccom)
throwaway(pl->pl_ccom); throwaway(pl->pl_ccom);
if (pl->pl_env) { /* The 'environment' for this plot. */ if (pl->pl_env)
/* va: HOW to do? */ free_struct_variable(pl->pl_env);
printf("va: killplot should tfree pl->pl_env=(%p)\n", pl->pl_env); if (pl->pl_lookup_table)
fflush(stdout); nghash_free(pl->pl_lookup_table, NULL, NULL);
} tfree(pl);
tfree(pl); /* va: also tfree pl itself (memory leak) */
} }
/* shared ngspice: remove plot 'const' upon 'quit'
constanplot is not dynamically allocated on the heap */
void void
destroy_const_plot(void) destroy_const_plot(void)
{ {
@ -892,14 +893,13 @@ destroy_const_plot(void)
vec_free(v); vec_free(v);
} }
wl_free(pl->pl_commands); wl_free(pl->pl_commands);
if (pl->pl_ccom) /* va: also tfree (memory leak) */ if (pl->pl_ccom)
throwaway(pl->pl_ccom); throwaway(pl->pl_ccom);
if (pl->pl_env) { /* The 'environment' for this plot. */ if (pl->pl_env)
/* va: HOW to do? */ free_struct_variable(pl->pl_env);
printf("va: killplot should tfree pl->pl_env=(%p)\n", pl->pl_env); if (pl->pl_lookup_table)
fflush(stdout); nghash_free(pl->pl_lookup_table, NULL, NULL);
}
} }