Browse Source

devices/asrc, rewrite #3/10, combine TSTALLOC and MY_TSTALLOC

pre-master-46
rlar 11 years ago
parent
commit
ce49a4977d
  1. 22
      src/spicelib/devices/asrc/asrcset.c

22
src/spicelib/devices/asrc/asrcset.c

@ -47,7 +47,7 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
/* macro to make elements with built in test for out of memory */ /* macro to make elements with built in test for out of memory */
#define TSTALLOC(ptr, first, second) \ #define TSTALLOC(ptr, first, second) \
do { if ((here->ptr = SMPmakeElt(matrix, here->first, here->second)) == NULL) { \
do { if ((here->ptr = SMPmakeElt(matrix, first, second)) == NULL) { \
return(E_NOMEM); \ return(E_NOMEM); \
} } while(0) } } while(0)
@ -70,10 +70,10 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 4); here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 4);
TSTALLOC(ASRCposptr[j++], ASRCposNode, ASRCbranch);
TSTALLOC(ASRCposptr[j++], ASRCnegNode, ASRCbranch);
TSTALLOC(ASRCposptr[j++], ASRCbranch, ASRCnegNode);
TSTALLOC(ASRCposptr[j++], ASRCbranch, ASRCposNode);
TSTALLOC(ASRCposptr[j++], here->ASRCposNode, here->ASRCbranch);
TSTALLOC(ASRCposptr[j++], here->ASRCnegNode, here->ASRCbranch);
TSTALLOC(ASRCposptr[j++], here->ASRCbranch, here->ASRCnegNode);
TSTALLOC(ASRCposptr[j++], here->ASRCbranch, here->ASRCposNode);
} }
for (i = 0; i < here->ASRCtree->numVars; i++) { for (i = 0; i < here->ASRCtree->numVars; i++) {
@ -88,12 +88,12 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
if (here->ASRCtype == ASRC_VOLTAGE) { if (here->ASRCtype == ASRC_VOLTAGE) {
/* CCVS */ /* CCVS */
here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 1); here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 1);
TSTALLOC(ASRCposptr[j++], ASRCbranch, ASRCcont_br);
TSTALLOC(ASRCposptr[j++], here->ASRCbranch, here->ASRCcont_br);
} else if (here->ASRCtype == ASRC_CURRENT) { } else if (here->ASRCtype == ASRC_CURRENT) {
/* CCCS */ /* CCCS */
here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 2); here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 2);
TSTALLOC(ASRCposptr[j++], ASRCposNode, ASRCcont_br);
TSTALLOC(ASRCposptr[j++], ASRCnegNode, ASRCcont_br);
TSTALLOC(ASRCposptr[j++], here->ASRCposNode, here->ASRCcont_br);
TSTALLOC(ASRCposptr[j++], here->ASRCnegNode, here->ASRCcont_br);
} else { } else {
return (E_BADPARM); return (E_BADPARM);
} }
@ -102,12 +102,12 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
if (here->ASRCtype == ASRC_VOLTAGE) { if (here->ASRCtype == ASRC_VOLTAGE) {
/* VCVS */ /* VCVS */
here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 1); here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 1);
MY_TSTALLOC(ASRCposptr[j++], ASRCbranch, here->ASRCtree->vars[i].nValue);
TSTALLOC(ASRCposptr[j++], here->ASRCbranch, here->ASRCtree->vars[i].nValue->number);
} else if (here->ASRCtype == ASRC_CURRENT) { } else if (here->ASRCtype == ASRC_CURRENT) {
/* VCCS */ /* VCCS */
here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 2); here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 2);
MY_TSTALLOC(ASRCposptr[j++], ASRCposNode, here->ASRCtree->vars[i].nValue);
MY_TSTALLOC(ASRCposptr[j++], ASRCnegNode, here->ASRCtree->vars[i].nValue);
TSTALLOC(ASRCposptr[j++], here->ASRCposNode, here->ASRCtree->vars[i].nValue->number);
TSTALLOC(ASRCposptr[j++], here->ASRCnegNode, here->ASRCtree->vars[i].nValue->number);
} else { } else {
return (E_BADPARM); return (E_BADPARM);
} }

Loading…
Cancel
Save