From 97d61c495f8356bfc50535af46846404ecaa7a8b Mon Sep 17 00:00:00 2001 From: rlar Date: Tue, 6 Mar 2018 21:30:00 +0100 Subject: [PATCH] rewrite-rw, TSTALLOC() --- src/spicelib/devices/csw/cswsetup.c | 12 ++++++------ src/spicelib/devices/sw/swsetup.c | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/spicelib/devices/csw/cswsetup.c b/src/spicelib/devices/csw/cswsetup.c index 3726de31a..d2a9bc23e 100644 --- a/src/spicelib/devices/csw/cswsetup.c +++ b/src/spicelib/devices/csw/cswsetup.c @@ -11,6 +11,12 @@ Author: 1985 Gordon Jacobs #include "ngspice/sperror.h" #include "ngspice/suffix.h" +#define TSTALLOC(ptr, first, second) \ + do { \ + if (!(here->ptr = SMPmakeElt(matrix, here->first, here->second))) \ + return E_NOMEM; \ + } while(0) + int CSWsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) @@ -53,12 +59,6 @@ CSWsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) return E_BADPARM; } -/* macro to make elements with built in test for out of memory */ -#define TSTALLOC(ptr,first,second) \ -do { if((here->ptr = SMPmakeElt(matrix, here->first, here->second)) == NULL){\ - return(E_NOMEM);\ -} } while(0) - TSTALLOC(CSWposPosPtr, CSWposNode, CSWposNode); TSTALLOC(CSWposNegPtr, CSWposNode, CSWnegNode); TSTALLOC(CSWnegPosPtr, CSWnegNode, CSWposNode); diff --git a/src/spicelib/devices/sw/swsetup.c b/src/spicelib/devices/sw/swsetup.c index be0f748c2..f9a6840cc 100644 --- a/src/spicelib/devices/sw/swsetup.c +++ b/src/spicelib/devices/sw/swsetup.c @@ -12,6 +12,12 @@ Author: 1985 Gordon Jacobs #include "ngspice/sperror.h" #include "ngspice/suffix.h" +#define TSTALLOC(ptr, first, second) \ + do { \ + if (!(here->ptr = SMPmakeElt(matrix, here->first, here->second))) \ + return E_NOMEM; \ + } while (0) + int SWsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) @@ -48,12 +54,6 @@ SWsetup(SMPmatrix *matrix, GENmodel *inModel, CKTcircuit *ckt, int *states) /* Default Value Processing for Switch Instance */ /* none */ -/* macro to make elements with built in test for out of memory */ -#define TSTALLOC(ptr,first,second) \ -do { if((here->ptr = SMPmakeElt(matrix, here->first, here->second)) == NULL){\ - return(E_NOMEM);\ -} } while(0) - TSTALLOC(SWposPosPtr, SWposNode, SWposNode); TSTALLOC(SWposNegPtr, SWposNode, SWnegNode); TSTALLOC(SWnegPosPtr, SWnegNode, SWposNode);