int CKTmodCrt(CKTcircuit *ckt, int type, GENmodel **modfast, IFuid name) { GENmodel *model = CKTfndMod(ckt, name); if (model) { *modfast = model; return E_EXISTS; } model = (GENmodel *) tmalloc((size_t) *(DEVices[type]->DEVmodSize)); if (!model) return E_NOMEM; model->GENmodType = type; model->GENmodName = name; model->GENnextModel = ckt->CKThead[type]; ckt->CKThead[type] = model; nghash_insert(ckt->MODnameHash, name, model); *modfast = model; return OK; }
///<param = *ckt> Circuit to operate on </param> ///<param = type> Type of model to create </param> ///<param = **modFast> Model being created </param> ///<param = name> Name of new model </param> int CKTmodCrt(GENERIC *ckt, int type, GENERIC **modfast, IFuid name) { extern SPICEdev *DEVices[]; GENmodel *mymodfast = NULL; int error; error = CKTfndMod(ckt, &type, (GENERIC**)&mymodfast, name); if (error == E_NOMOD) { mymodfast = (GENmodel *)MALLOC(*DEVices[type]->DEVmodSize); if (mymodfast == (GENmodel *)NULL) return(E_NOMEM); mymodfast->GENmodType = type; mymodfast->GENmodName = name; mymodfast->GENnextModel = (GENmodel *)((CKTcircuit *)ckt)->CKThead[type]; ((CKTcircuit *)ckt)->CKThead[type] = (GENmodel *)mymodfast; if (modfast) *modfast = (GENERIC *)mymodfast; return(OK); } else if (error == 0) { if (modfast) *modfast = (GENERIC *)mymodfast; return(E_EXISTS); } else { return(error); } /*NOTREACHED*/ }