plug memory leaks for the 'plot' command
This commit is contained in:
parent
82aad9d5b7
commit
b343bc8803
|
|
@ -38,6 +38,7 @@ extern void rem_controls(void);
|
||||||
|
|
||||||
extern IFsimulator SIMinfo;
|
extern IFsimulator SIMinfo;
|
||||||
extern void spice_destroy_devices(void); /* FIXME need a better place */
|
extern void spice_destroy_devices(void); /* FIXME need a better place */
|
||||||
|
extern void pl_rempar(void); /* plotit.c */
|
||||||
static void byemesg(void);
|
static void byemesg(void);
|
||||||
static int confirm_quit(void);
|
static int confirm_quit(void);
|
||||||
|
|
||||||
|
|
@ -56,6 +57,7 @@ com_quit(wordlist *wl)
|
||||||
gr_clean();
|
gr_clean();
|
||||||
cp_ccon(FALSE);
|
cp_ccon(FALSE);
|
||||||
|
|
||||||
|
|
||||||
/* Make sure the guy really wants to quit. */
|
/* Make sure the guy really wants to quit. */
|
||||||
if (!ft_nutmeg)
|
if (!ft_nutmeg)
|
||||||
if (!noask && !confirm_quit())
|
if (!noask && !confirm_quit())
|
||||||
|
|
@ -90,6 +92,9 @@ com_quit(wordlist *wl)
|
||||||
cp_destroy_keywords();
|
cp_destroy_keywords();
|
||||||
destroy_ivars();
|
destroy_ivars();
|
||||||
#else
|
#else
|
||||||
|
/* remove plotting parameters */
|
||||||
|
pl_rempar();
|
||||||
|
|
||||||
while (ft_curckt)
|
while (ft_curckt)
|
||||||
com_remcirc(NULL);
|
com_remcirc(NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,28 @@
|
||||||
#include "graf.h"
|
#include "graf.h"
|
||||||
|
|
||||||
static bool sameflag;
|
static bool sameflag;
|
||||||
|
/* All these things are static so that "samep" will work.
|
||||||
|
They are outside of plotit() to allow deleting */
|
||||||
|
static double *xcompress = NULL, *xindices = NULL;
|
||||||
|
static double *xlim = NULL, *ylim = NULL;
|
||||||
|
static double *xdelta = NULL, *ydelta = NULL;
|
||||||
|
static char *xlabel = NULL, *ylabel = NULL, *title = NULL;
|
||||||
#ifdef TCL_MODULE
|
#ifdef TCL_MODULE
|
||||||
#include "ngspice/tclspice.h"
|
#include "ngspice/tclspice.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* remove the malloced parameters upon ngspice quit */
|
||||||
|
void pl_rempar(void)
|
||||||
|
{
|
||||||
|
txfree(xcompress);
|
||||||
|
txfree(xindices);
|
||||||
|
txfree(xlim);
|
||||||
|
txfree(ylim);
|
||||||
|
txfree(xdelta);
|
||||||
|
txfree(ydelta);
|
||||||
|
txfree(xlabel);
|
||||||
|
txfree(ylabel);
|
||||||
|
}
|
||||||
|
|
||||||
static struct dvec *vec_self(struct dvec *v);
|
static struct dvec *vec_self(struct dvec *v);
|
||||||
static struct dvec *vec_scale(struct dvec *v);
|
static struct dvec *vec_scale(struct dvec *v);
|
||||||
|
|
@ -258,11 +275,6 @@ bool plotit(wordlist *wl, const char *hcopy, const char *devname)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* All these things are static so that "samep" will work. */
|
|
||||||
static double *xcompress = NULL, *xindices = NULL;
|
|
||||||
static double *xlim = NULL, *ylim = NULL;
|
|
||||||
static double *xdelta = NULL, *ydelta = NULL;
|
|
||||||
static char *xlabel = NULL, *ylabel = NULL, *title = NULL;
|
|
||||||
static bool nointerp = FALSE;
|
static bool nointerp = FALSE;
|
||||||
static GRIDTYPE gtype = GRID_LIN;
|
static GRIDTYPE gtype = GRID_LIN;
|
||||||
static PLOTTYPE ptype = PLOT_LIN;
|
static PLOTTYPE ptype = PLOT_LIN;
|
||||||
|
|
@ -317,8 +329,10 @@ bool plotit(wordlist *wl, const char *hcopy, const char *devname)
|
||||||
/* Build the plot command. This construction had been done with wordlists
|
/* Build the plot command. This construction had been done with wordlists
|
||||||
* and reversing, and flattening, but it is clearer as well as much more
|
* and reversing, and flattening, but it is clearer as well as much more
|
||||||
* efficient to use a dstring. */
|
* efficient to use a dstring. */
|
||||||
rc_ds |= ds_cat_printf(&ds_cline, "plot %s", wl_flatten(wwl->wl_next));
|
char *flatstr = wl_flatten(wwl->wl_next);
|
||||||
|
rc_ds |= ds_cat_printf(&ds_cline, "plot %s", flatstr);
|
||||||
wl_free(wwl);
|
wl_free(wwl);
|
||||||
|
tfree(flatstr);
|
||||||
|
|
||||||
/* Add title, xlabel or ylabel, if available, with quotes ''. */
|
/* Add title, xlabel or ylabel, if available, with quotes ''. */
|
||||||
if (nxlabel) {
|
if (nxlabel) {
|
||||||
|
|
@ -343,6 +357,7 @@ bool plotit(wordlist *wl, const char *hcopy, const char *devname)
|
||||||
sameflag = getflag(wl, "samep");
|
sameflag = getflag(wl, "samep");
|
||||||
|
|
||||||
if (!sameflag || !xlim) {
|
if (!sameflag || !xlim) {
|
||||||
|
txfree(xlim);
|
||||||
xlim = getlims(wl, "xl", 2);
|
xlim = getlims(wl, "xl", 2);
|
||||||
if (!xlim) {
|
if (!xlim) {
|
||||||
xlim = getlims(wl, "xlimit", 2);
|
xlim = getlims(wl, "xlimit", 2);
|
||||||
|
|
@ -354,6 +369,7 @@ bool plotit(wordlist *wl, const char *hcopy, const char *devname)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sameflag || !ylim) {
|
if (!sameflag || !ylim) {
|
||||||
|
txfree(ylim);
|
||||||
ylim = getlims(wl, "yl", 2);
|
ylim = getlims(wl, "yl", 2);
|
||||||
if (!ylim) {
|
if (!ylim) {
|
||||||
ylim = getlims(wl, "ylimit", 2);
|
ylim = getlims(wl, "ylimit", 2);
|
||||||
|
|
@ -365,6 +381,7 @@ bool plotit(wordlist *wl, const char *hcopy, const char *devname)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sameflag || !xcompress) {
|
if (!sameflag || !xcompress) {
|
||||||
|
txfree(xcompress);
|
||||||
xcompress = getlims(wl, "xcompress", 1);
|
xcompress = getlims(wl, "xcompress", 1);
|
||||||
if (!xcompress) {
|
if (!xcompress) {
|
||||||
xcompress = getlims(wl, "xcomp", 1);
|
xcompress = getlims(wl, "xcomp", 1);
|
||||||
|
|
@ -376,6 +393,7 @@ bool plotit(wordlist *wl, const char *hcopy, const char *devname)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sameflag || !xindices) {
|
if (!sameflag || !xindices) {
|
||||||
|
txfree(xindices);
|
||||||
xindices = getlims(wl, "xindices", 2);
|
xindices = getlims(wl, "xindices", 2);
|
||||||
if (!xindices) {
|
if (!xindices) {
|
||||||
xindices = getlims(wl, "xind", 2);
|
xindices = getlims(wl, "xind", 2);
|
||||||
|
|
@ -387,6 +405,7 @@ bool plotit(wordlist *wl, const char *hcopy, const char *devname)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sameflag || !xdelta) {
|
if (!sameflag || !xdelta) {
|
||||||
|
txfree(xdelta);
|
||||||
xdelta = getlims(wl, "xdelta", 1);
|
xdelta = getlims(wl, "xdelta", 1);
|
||||||
if (!xdelta) {
|
if (!xdelta) {
|
||||||
xdelta = getlims(wl, "xdel", 1);
|
xdelta = getlims(wl, "xdel", 1);
|
||||||
|
|
@ -397,6 +416,7 @@ bool plotit(wordlist *wl, const char *hcopy, const char *devname)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sameflag || !ydelta) {
|
if (!sameflag || !ydelta) {
|
||||||
|
txfree(ydelta);
|
||||||
ydelta = getlims(wl, "ydelta", 1);
|
ydelta = getlims(wl, "ydelta", 1);
|
||||||
if (!ydelta) {
|
if (!ydelta) {
|
||||||
ydelta = getlims(wl, "ydel", 1);
|
ydelta = getlims(wl, "ydel", 1);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue