CKTfndDev(), return the found instance instead of error code
now if (fast != NULL) CKTfndDev(,,fast, ) is equivalent to *fast = CKTfndDev(,,fast, )
This commit is contained in:
parent
7bacfc73d1
commit
5daa676163
|
|
@ -615,7 +615,7 @@ finddev_special(
|
|||
int type = -1;
|
||||
|
||||
// assert(third && *third == NULL); for all invocations
|
||||
err = ft_sim->findInstance (ckt, &type, devptr, name);
|
||||
*devptr = ft_sim->findInstance (ckt, &type, devptr, name);
|
||||
err = *devptr ? OK : E_NODEV;
|
||||
if (err == OK) {
|
||||
*device_or_model = 0;
|
||||
|
|
@ -1218,7 +1218,7 @@ finddev(CKTcircuit *ckt, char *name, GENinstance **devptr, GENmodel **modptr)
|
|||
int type = -1;
|
||||
|
||||
// assert(third && *third == NULL); for all invocations
|
||||
err = ft_sim->findInstance (ckt, &type, devptr, name);
|
||||
*devptr = ft_sim->findInstance (ckt, &type, devptr, name);
|
||||
err = *devptr ? OK : E_NODEV;
|
||||
if (err == OK)
|
||||
return (type);
|
||||
|
|
|
|||
|
|
@ -319,7 +319,7 @@ extern void NDEVacct(CKTcircuit *ckt, FILE *file);
|
|||
extern void CKTncDump(CKTcircuit *);
|
||||
extern int CKTfndAnal(CKTcircuit *, int *, JOB **, IFuid , TSKtask *, IFuid);
|
||||
extern int CKTfndBranch(CKTcircuit *, IFuid);
|
||||
extern int CKTfndDev(CKTcircuit *, int *, GENinstance **, IFuid);
|
||||
extern GENinstance *CKTfndDev(CKTcircuit *, int *, GENinstance **, IFuid);
|
||||
extern int CKTfndMod(CKTcircuit *, int *, GENmodel **, IFuid);
|
||||
extern int CKTfndNode(CKTcircuit *, CKTnode **, IFuid);
|
||||
extern int CKTfndTask(CKTcircuit *, TSKtask **, IFuid );
|
||||
|
|
|
|||
|
|
@ -370,7 +370,7 @@ struct IFsimulator {
|
|||
/* set a parameter on an instance */
|
||||
int (*askInstanceQuest) (CKTcircuit *, GENinstance *, int, IFvalue *, IFvalue *);
|
||||
/* ask a question about an instance */
|
||||
int (*findInstance) (CKTcircuit *, int *, GENinstance **, IFuid);
|
||||
GENinstance *(*findInstance) (CKTcircuit *, int *, GENinstance **, IFuid);
|
||||
/* find a specific instance */
|
||||
int (*deleteInstance) (CKTcircuit *, void *);
|
||||
/* delete an instance from the circuit */
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ NOISEan (CKTcircuit *ckt, int restart)
|
|||
code = CKTtypelook("Vsource");
|
||||
if (code != -1) {
|
||||
// assert(third && *third == NULL);
|
||||
error = CKTfndDev(ckt, NULL, &inst, job->input);
|
||||
inst = CKTfndDev(ckt, NULL, &inst, job->input);
|
||||
error = inst ? OK : E_NODEV;
|
||||
if (!error && !((VSRCinstance *)inst)->VSRCacGiven) {
|
||||
errMsg = TMALLOC(char, strlen(noacinput) + 1);
|
||||
|
|
@ -61,7 +61,7 @@ NOISEan (CKTcircuit *ckt, int restart)
|
|||
code = CKTtypelook("Isource");
|
||||
if (code != -1 && inst==NULL) {
|
||||
// assert(third && *third == NULL);
|
||||
error = CKTfndDev(ckt, NULL, &inst, job->input);
|
||||
inst = CKTfndDev(ckt, NULL, &inst, job->input);
|
||||
error = inst ? OK : E_NODEV;
|
||||
if (error) {
|
||||
/* XXX ??? */
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ TFanal(CKTcircuit *ckt, int restart)
|
|||
Vtype = CKTtypelook("Vsource");
|
||||
if(Itype != -1) {
|
||||
// assert(third && *third == NULL);
|
||||
error = CKTfndDev(ckt, NULL, &ptr, job->TFinSrc);
|
||||
ptr = CKTfndDev(ckt, NULL, &ptr, job->TFinSrc);
|
||||
error = ptr ? OK : E_NODEV;
|
||||
if(error ==0) {
|
||||
job->TFinIsI = 1;
|
||||
|
|
@ -64,7 +64,7 @@ TFanal(CKTcircuit *ckt, int restart)
|
|||
|
||||
if( (Vtype != -1) && (ptr==NULL) ) {
|
||||
// assert(third && *third == NULL);
|
||||
error = CKTfndDev(ckt, NULL, &ptr, job->TFinSrc);
|
||||
ptr = CKTfndDev(ckt, NULL, &ptr, job->TFinSrc);
|
||||
error = ptr ? OK : E_NODEV;
|
||||
job->TFinIsV = 1;
|
||||
job->TFinIsI = 0;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ CKTcrtElt(CKTcircuit *ckt, GENmodel *modPtr, GENinstance **inInstPtr, IFuid name
|
|||
return E_NOMOD;
|
||||
|
||||
// assert(third && *third == NULL);
|
||||
error = CKTfndDev(ckt, NULL, &instPtr, name);
|
||||
instPtr = CKTfndDev(ckt, NULL, &instPtr, name);
|
||||
error = instPtr ? OK : E_NODEV;
|
||||
|
||||
if (error == OK) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ Author: 1985 Thomas L. Quarles
|
|||
#include "string.h"
|
||||
|
||||
|
||||
int
|
||||
GENinstance *
|
||||
CKTfndDev(CKTcircuit *ckt, int *type, GENinstance **fast, IFuid name)
|
||||
{
|
||||
GENinstance *here;
|
||||
|
|
@ -19,7 +19,7 @@ CKTfndDev(CKTcircuit *ckt, int *type, GENinstance **fast, IFuid name)
|
|||
if (fast && *fast) {
|
||||
if (type)
|
||||
*type = (*fast)->GENmodPtr->GENmodType;
|
||||
return OK;
|
||||
return *fast;
|
||||
}
|
||||
|
||||
here = nghash_find(ckt->DEVnameHash, name);
|
||||
|
|
@ -32,8 +32,8 @@ CKTfndDev(CKTcircuit *ckt, int *type, GENinstance **fast, IFuid name)
|
|||
if (type)
|
||||
*type = here->GENmodPtr->GENmodType;
|
||||
|
||||
return OK;
|
||||
return here;
|
||||
}
|
||||
|
||||
return E_NODEV;
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ MUTsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
|
|||
}
|
||||
|
||||
// assert(third);
|
||||
error = CKTfndDev(ckt, NULL, (GENinstance **) &(here->MUTind1), here->MUTindName1);
|
||||
here->MUTind1 = (INDinstance *) CKTfndDev(ckt, NULL, (GENinstance **) &(here->MUTind1), here->MUTindName1);
|
||||
error = here->MUTind1 ? OK : E_NODEV;
|
||||
if(error) {
|
||||
IFuid namarray[2];
|
||||
|
|
@ -55,7 +55,7 @@ MUTsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
|
|||
namarray);
|
||||
}
|
||||
// assert(third);
|
||||
error = CKTfndDev(ckt, NULL, (GENinstance **) &(here->MUTind2), here->MUTindName2);
|
||||
here->MUTind2 = (INDinstance *) CKTfndDev(ckt, NULL, (GENinstance **) &(here->MUTind2), here->MUTindName2);
|
||||
error = here->MUTind2 ? OK : E_NODEV;
|
||||
if(error) {
|
||||
IFuid namarray[2];
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ INPaName(char *parm, IFvalue * val, CKTcircuit *ckt, int *dev, char *devnam,
|
|||
* WILL be set on return unless error is not OK
|
||||
*/
|
||||
// assert(third) for all invocations
|
||||
error = sim->findInstance (ckt, dev, fast, devnam);
|
||||
*fast = sim->findInstance (ckt, dev, fast, devnam);
|
||||
error = *fast ? OK : E_NODEV;
|
||||
if (error)
|
||||
return (error);
|
||||
|
|
|
|||
|
|
@ -1395,7 +1395,7 @@ get_mod_param TCL_CMDPROCARGS(clientData, interp, argc, argv)
|
|||
/* get the unique IFuid for name (device/model) */
|
||||
INPretrieve(&name, ft_curckt->ci_symtab);
|
||||
// assert(third && *third == NULL);
|
||||
err = ft_sim->findInstance (ft_curckt->ci_ckt, &typecode, &devptr, name);
|
||||
devptr = ft_sim->findInstance (ft_curckt->ci_ckt, &typecode, &devptr, name);
|
||||
err = devptr ? OK : E_NODEV;
|
||||
if (err != OK) {
|
||||
typecode = -1;
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ SENstartup(CKTcircuit *ckt, int restart)
|
|||
fast = NULL;
|
||||
|
||||
// assert(third && *third == NULL);
|
||||
err = CKTfndDev(ckt, &type, &fast, ckt->CKTsenInfo->SENdevices[i]);
|
||||
fast = CKTfndDev(ckt, &type, &fast, ckt->CKTsenInfo->SENdevices[i]);
|
||||
err = fast ? OK : E_NODEV;
|
||||
if (err != OK)
|
||||
return err;
|
||||
|
|
|
|||
Loading…
Reference in New Issue