remove memory leak freeing dicoS

reported by Jonathan Knott
This commit is contained in:
h_vogt
2013-12-31 16:13:19 +01:00
committed by rlar
parent 4635a19ba9
commit da10f49755
4 changed files with 32 additions and 16 deletions
+5
View File
@@ -634,6 +634,11 @@ inp_spsource(FILE *fp, bool comfile, char *filename, bool intfile)
prev_card = dd;
} //end of for-loop
/* If we don't have .meas lines, we free the dicoS structure now.
If we have .meas lines, dicoS is freed in do_measure() */
if (ft_curckt && !ft_curckt->ci_meas)
nupa_del_dicoS();
/* set temperature, if defined, to new value.
cp_vset will set the variable "temp" and also set CKTtemp,
so we can do it only here because the circuit has to be already there */
+3
View File
@@ -431,6 +431,9 @@ do_measure(
txfree(an_name);
/* numparam data structure dicoS is no longer needed */
nupa_del_dicoS();
fflush(stdout);
return(measures_passed);
+1
View File
@@ -20,6 +20,7 @@ extern double nupa_get_param(char *param_name, int *found);
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 dynMaxckt; /* number of lines in deck after expansion */
+23 -16
View File
@@ -472,6 +472,26 @@ nupa_init(char *srcfile)
}
/* free dicoS (called from do_measure() in measure.c or
immediately from inp_spsource() in inp.c) */
void
nupa_del_dicoS(void)
{
int i;
if(!dicoS)
return;
for (i = dynmaxline; i >= 0; i--)
dispose(dicoS->dynrefptr[i]);
dispose(dicoS->dynrefptr);
dispose(dicoS->dyncategory);
dispose(dicoS);
dicoS = NULL;
}
static void
nupa_done(void)
{
@@ -490,22 +510,9 @@ nupa_done(void)
nerrors = dicoS->errcount;
dictsize = donedico(dicoS);
/* We cannot remove dico here because numparam is usedby
the .measure statement, which is invoked only after the
simulation has finished */
/*
* for (i = dynmaxline; i >= 0; i--) {
* dispose(dico->dynrefptr[i]);
* }
* dispose(dico->dynrefptr);
* dispose(dico->dyncategory);
* dispose(dico->dyndat);
* dispose(dico);
* dico = NULL;
* dispose(inst_dico->dyndat);
* dispose(inst_dico);
* inst_dico = NULL;
*/
/* We cannot remove dicoS here because numparam is used by
the .measure statements, which are invoked only after the
simulation has finished. */
if (nerrors) {
/* debug: ask if spice run really wanted */