devices/asrc, rewrite #2/10, simplify incremental memory allocation
This commit is contained in:
parent
e13e1690d2
commit
e902ebd34d
|
|
@ -20,7 +20,6 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
|
||||||
ASRCinstance *here;
|
ASRCinstance *here;
|
||||||
ASRCmodel *model = (ASRCmodel*) inModel;
|
ASRCmodel *model = (ASRCmodel*) inModel;
|
||||||
int error, i, j;
|
int error, i, j;
|
||||||
int v_first;
|
|
||||||
CKTnode *tmp;
|
CKTnode *tmp;
|
||||||
|
|
||||||
NG_IGNORE(states);
|
NG_IGNORE(states);
|
||||||
|
|
@ -37,7 +36,6 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
|
||||||
|
|
||||||
here->ASRCposptr = NULL;
|
here->ASRCposptr = NULL;
|
||||||
j = 0; /* strchr of the array holding ptrs to SMP */
|
j = 0; /* strchr of the array holding ptrs to SMP */
|
||||||
v_first = 1;
|
|
||||||
|
|
||||||
if (here->ASRCtype == ASRC_VOLTAGE)
|
if (here->ASRCtype == ASRC_VOLTAGE)
|
||||||
if (here->ASRCbranch == 0) {
|
if (here->ASRCbranch == 0) {
|
||||||
|
|
@ -70,7 +68,7 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
|
||||||
return(E_UNSUPP);
|
return(E_UNSUPP);
|
||||||
}
|
}
|
||||||
|
|
||||||
here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 5);
|
here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 4);
|
||||||
|
|
||||||
TSTALLOC(ASRCposptr[j++], ASRCposNode, ASRCbranch);
|
TSTALLOC(ASRCposptr[j++], ASRCposNode, ASRCbranch);
|
||||||
TSTALLOC(ASRCposptr[j++], ASRCnegNode, ASRCbranch);
|
TSTALLOC(ASRCposptr[j++], ASRCnegNode, ASRCbranch);
|
||||||
|
|
@ -89,13 +87,8 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
|
||||||
}
|
}
|
||||||
if (here->ASRCtype == ASRC_VOLTAGE) {
|
if (here->ASRCtype == ASRC_VOLTAGE) {
|
||||||
/* CCVS */
|
/* CCVS */
|
||||||
if (v_first) {
|
here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 1);
|
||||||
TSTALLOC(ASRCposptr[j++], ASRCbranch, ASRCcont_br);
|
TSTALLOC(ASRCposptr[j++], ASRCbranch, ASRCcont_br);
|
||||||
v_first = 0;
|
|
||||||
} else {
|
|
||||||
here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 1);
|
|
||||||
TSTALLOC(ASRCposptr[j++], ASRCbranch, 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);
|
||||||
|
|
@ -108,13 +101,8 @@ ASRCsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states)
|
||||||
case IF_NODE:
|
case IF_NODE:
|
||||||
if (here->ASRCtype == ASRC_VOLTAGE) {
|
if (here->ASRCtype == ASRC_VOLTAGE) {
|
||||||
/* VCVS */
|
/* VCVS */
|
||||||
if (v_first) {
|
here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 1);
|
||||||
MY_TSTALLOC(ASRCposptr[j++], ASRCbranch, here->ASRCtree->vars[i].nValue);
|
MY_TSTALLOC(ASRCposptr[j++], ASRCbranch, here->ASRCtree->vars[i].nValue);
|
||||||
v_first = 0;
|
|
||||||
} else {
|
|
||||||
here->ASRCposptr = TREALLOC(double *, here->ASRCposptr, j + 1);
|
|
||||||
MY_TSTALLOC(ASRCposptr[j++], ASRCbranch, here->ASRCtree->vars[i].nValue);
|
|
||||||
}
|
|
||||||
} 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);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue