Store the numparam dicoS structure for each circuit in a list.
Functions to add, remove, retrive dicoS from the list and to update dicoS, if the circuit has been changed. Keeping dicoS is necessary because it may be used by measure. This patch prevents (huge) memory leaks by overwriting dicoS if multiple calls to the 'source' command are executed.
This commit is contained in:
parent
4a3f02e979
commit
1066bf0a7b
|
|
@ -1057,8 +1057,9 @@ inp_dodeck(
|
|||
ct->ci_inprogress = FALSE;
|
||||
ct->ci_runonce = FALSE;
|
||||
ct->ci_commands = end;
|
||||
ct->ci_dicos = nupa_add_dicoslist();
|
||||
/* prevent false reads in multi-threaded ngshared */
|
||||
#ifndef SHARED_MODULE
|
||||
#ifndef SHARED_MODULE
|
||||
if (reuse)
|
||||
tfree(ct->ci_filename);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -23,6 +23,9 @@ extern void nupa_add_param(char *param_name, double value);
|
|||
extern void nupa_add_inst_param(char *param_name, double value);
|
||||
extern void nupa_copy_inst_dico(void);
|
||||
extern void nupa_del_dicoS(void);
|
||||
extern int nupa_add_dicoslist(void);
|
||||
extern void nupa_rem_dicoslist(int);
|
||||
extern void nupa_set_dicoslist(int);
|
||||
|
||||
extern int dynMaxckt; /* number of lines in deck after expansion */
|
||||
|
||||
|
|
|
|||
|
|
@ -297,6 +297,7 @@ static bool inexpansionS = 0; /* flag subckt expansion phase */
|
|||
static bool incontrolS = 0; /* flag control code sections */
|
||||
static bool firstsignalS = 1;
|
||||
static dico_t *dicoS = NULL;
|
||||
static dico_t *dicos_list[100];
|
||||
|
||||
|
||||
static void
|
||||
|
|
@ -685,3 +686,36 @@ nupa_signal(int sig)
|
|||
firstsignalS = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Store dicoS for each circuit loaded.
|
||||
The return value will be stored in ft_curckt->ci_dicos.
|
||||
We need to keep dicoS because it may be used by measure. */
|
||||
int
|
||||
nupa_add_dicoslist(void)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 100; i++)
|
||||
if (dicos_list[i] == NULL) {
|
||||
dicos_list[i] = dicoS;
|
||||
break;
|
||||
}
|
||||
|
||||
return (i);
|
||||
}
|
||||
|
||||
|
||||
/* remove dicoS from list if circuit is removed */
|
||||
void
|
||||
nupa_rem_dicoslist(int ir)
|
||||
{
|
||||
dicos_list[ir] = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* change dicoS to the active circuit */
|
||||
void
|
||||
nupa_set_dicoslist(int ir)
|
||||
{
|
||||
dicoS = dicos_list[ir];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ Modified: 2000 AlansFixes
|
|||
#include "ngspice/ftedebug.h"
|
||||
#include "ngspice/dvec.h"
|
||||
|
||||
#include "numparam/numpaif.h"
|
||||
|
||||
#include "circuits.h"
|
||||
#include "completion.h"
|
||||
#include "runcoms.h"
|
||||
|
|
@ -108,6 +110,8 @@ com_scirc(wordlist *wl)
|
|||
modtab = ft_curckt->ci_modtab;
|
||||
/* get the database for save, iplot, stop */
|
||||
dbs = ft_curckt->ci_dbs;
|
||||
/* set the numparam dicos structure for use with measure */
|
||||
nupa_set_dicoslist(ft_curckt->ci_dicos);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -222,6 +222,8 @@ com_remcirc(wordlist *wl)
|
|||
|
||||
/* delete numparam data structure dicoS */
|
||||
nupa_del_dicoS();
|
||||
/* delete entry in dicoslist */
|
||||
nupa_rem_dicoslist(ft_curckt->ci_dicos);
|
||||
|
||||
dbfree(ft_curckt->ci_dbs);
|
||||
ft_curckt->ci_dbs = NULL;
|
||||
|
|
@ -283,5 +285,6 @@ com_remcirc(wordlist *wl)
|
|||
if (ft_curckt) {
|
||||
modtab = ft_curckt->ci_modtab;
|
||||
dbs = ft_curckt->ci_dbs;
|
||||
nupa_set_dicoslist(ft_curckt->ci_dicos);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,6 +56,8 @@ struct circ {
|
|||
JOB *ci_curOpt; /* most recent options anal. for the circuit */
|
||||
char *ci_last_an; /* name of last analysis run */
|
||||
|
||||
int ci_dicos; /* index to the numparam dicoS structure
|
||||
for this circuit */
|
||||
struct pt_temper *modtlist; /* all expressions with 'temper'
|
||||
in .model lines */
|
||||
struct pt_temper *devtlist; /* all expressions with 'temper'
|
||||
|
|
|
|||
Loading…
Reference in New Issue