Browse Source

introduce GENinstanceFree() and GENmodelFree()

To abstract away the business of releasing the memory
  of a struct GENmodel or struct GENinstance.
pre-master-46
rlar 8 years ago
parent
commit
41c0ee45a2
  1. 2
      src/frontend/spiceif.c
  2. 5
      src/include/ngspice/gendefs.h
  3. 4
      src/spicelib/analysis/cktdest.c
  4. 4
      src/spicelib/analysis/cktdltm.c
  5. 14
      src/spicelib/analysis/cktmcrt.c

2
src/frontend/spiceif.c

@ -898,7 +898,7 @@ if_setparam_model(CKTcircuit *ckt, char **name, char *val)
INPgetMod(ckt, mods->GENmodName, &inpmod, ft_curckt->ci_symtab);
if (curMod != nghash_delete(ckt->MODnameHash, curMod->GENmodName))
fprintf(stderr, "ERROR, ouch nasal daemons ...\n");
FREE(mods);
GENmodelFree(mods);
inpmod->INPmodfast = NULL;
break;

5
src/include/ngspice/gendefs.h

@ -46,4 +46,9 @@ struct GENmodel { /* model structure for a resistor */
IFuid GENmodName; /* pointer to character string naming this model */
};
void GENinstanceFree(GENinstance *);
void GENmodelFree(GENmodel *);
#endif

4
src/spicelib/analysis/cktdest.c

@ -47,12 +47,12 @@ CKTdestroy(CKTcircuit *ckt)
GENinstance *next_inst = inst->GENnextInstance;
if (DEVices[i]->DEVdelete)
DEVices[i]->DEVdelete(inst);
FREE(inst);
GENinstanceFree(inst);
inst = next_inst;
}
if (DEVices[i]->DEVmodDelete)
DEVices[i]->DEVmodDelete(model);
FREE(model);
GENmodelFree(model);
model = next_model;
}
if (DEVices[i]->DEVdestroy)

4
src/spicelib/analysis/cktdltm.c

@ -37,11 +37,11 @@ CKTdltMod(CKTcircuit *ckt, GENmodel *m)
fprintf(stderr, "ERROR, ouch nasal daemons ...\n");
error = SPfrontEnd->IFdelUid (ckt, h->GENname,
UID_INSTANCE);
tfree(h);
GENinstanceFree(h);
}
if (m != nghash_delete(ckt->MODnameHash, m->GENmodName))
fprintf(stderr, "ERROR, ouch nasal daemons ...\n");
error = SPfrontEnd->IFdelUid (ckt, m->GENmodName, UID_MODEL);
tfree(m);
GENmodelFree(m);
return(OK);
}

14
src/spicelib/analysis/cktmcrt.c

@ -42,3 +42,17 @@ CKTmodCrt(CKTcircuit *ckt, int type, GENmodel **modfast, IFuid name)
return OK;
}
void
GENinstanceFree(GENinstance *inst)
{
txfree(inst);
}
void
GENmodelFree(GENmodel *model)
{
txfree(model);
}
Loading…
Cancel
Save