From ade2f8c2c234ae973f210048dafb3257a210c73b Mon Sep 17 00:00:00 2001 From: rlar Date: Wed, 17 Jul 2013 20:42:00 +0200 Subject: [PATCH] CKTmodCrt(), cleanup --- src/spicelib/analysis/cktmcrt.c | 37 ++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/spicelib/analysis/cktmcrt.c b/src/spicelib/analysis/cktmcrt.c index 4508759d0..b41c67039 100644 --- a/src/spicelib/analysis/cktmcrt.c +++ b/src/spicelib/analysis/cktmcrt.c @@ -20,22 +20,25 @@ Author: 1985 Thomas L. Quarles int CKTmodCrt(CKTcircuit *ckt, int type, GENmodel **modfast, IFuid name) { - GENmodel *mymodfast = NULL; - - mymodfast = CKTfndMod(ckt, name); - if(!mymodfast) { - mymodfast = (GENmodel *) tmalloc((size_t) *(DEVices[type]->DEVmodSize)); - if(mymodfast == NULL) return(E_NOMEM); - mymodfast->GENmodType = type; - mymodfast->GENmodName = name; - mymodfast->GENnextModel = ckt->CKThead[type]; - ckt->CKThead[type] = mymodfast; - nghash_insert(ckt->MODnameHash, name, mymodfast); - *modfast = mymodfast; - return(OK); - } else { - *modfast = mymodfast; - return(E_EXISTS); + GENmodel *model = CKTfndMod(ckt, name); + + if (model) { + *modfast = model; + return E_EXISTS; } - /*NOTREACHED*/ + + 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; }