Browse Source

CKTfndDev(), rewrite

pre-master-46
Henrik Forstén 13 years ago
committed by rlar
parent
commit
771d1fa697
  1. 56
      src/spicelib/devices/cktfinddev.c

56
src/spicelib/devices/cktfinddev.c

@ -14,7 +14,6 @@ int
CKTfndDev(CKTcircuit *ckt, int *type, GENinstance **fast, IFuid name, GENmodel *modfast) CKTfndDev(CKTcircuit *ckt, int *type, GENinstance **fast, IFuid name, GENmodel *modfast)
{ {
GENinstance *here; GENinstance *here;
GENmodel *mods;
/* we know the device instance `fast' */ /* we know the device instance `fast' */
if (fast && *fast) { if (fast && *fast) {
@ -23,57 +22,18 @@ CKTfndDev(CKTcircuit *ckt, int *type, GENinstance **fast, IFuid name, GENmodel *
return OK; return OK;
} }
/* we know the model `modfast', but need to find the device instance */
if (modfast) {
here = nghash_find(ckt->DEVnameHash, name);
if (here && here->GENmodPtr == modfast) {
if (fast)
*fast = here;
here = nghash_find(ckt->DEVnameHash, name);
if (type)
*type = modfast->GENmodType;
if (here) {
return OK;
}
return E_NODEV;
}
if (fast)
*fast = here;
/* we know device `type', but need to find model and device instance */
if (*type >= 0 && *type < DEVmaxnum) {
/* look through all models */
for (mods = ckt->CKThead[*type]; mods ; mods = mods->GENnextModel) {
/* and all instances */
here = nghash_find(ckt->DEVnameHash, name);
if (here && here->GENmodPtr == mods) {
if (fast)
*fast = here;
return OK;
}
if (mods->GENmodName == NULL)
return E_NODEV;
}
return E_NOMOD;
}
if (type)
*type = here->GENmodPtr->GENmodType;
/* we don't even know `type', search all of them */
if (*type == -1) {
for (*type = 0; *type < DEVmaxnum; (*type)++) {
/* look through all models */
for (mods = ckt->CKThead[*type]; mods; mods = mods->GENnextModel) {
/* and all instances */
here = nghash_find(ckt->DEVnameHash, name);
if (here && here->GENmodPtr == mods) {
if (fast)
*fast = here;
return OK;
}
if (mods->GENmodName == NULL)
return E_NODEV;
}
}
*type = -1;
return E_NODEV;
return OK;
} }
return E_BADPARM;
return E_NODEV;
} }
Loading…
Cancel
Save