diff --git a/src/include/ngspice/spmatrix.h b/src/include/ngspice/spmatrix.h index 6148755da..c4151aca7 100644 --- a/src/include/ngspice/spmatrix.h +++ b/src/include/ngspice/spmatrix.h @@ -271,7 +271,7 @@ typedef spGenericPtr spMatrix; typedef spREAL spElement; /*! Declares the type of the Sparse error codes. */ -typedef int spError; +//typedef int spError; @@ -313,12 +313,12 @@ typedef struct MatrixFrame *MatrixPtr; spcEXTERN void spClear( MatrixPtr ); spcEXTERN spREAL spCondition( MatrixPtr, spREAL, int* ); -spcEXTERN MatrixPtr spCreate( int, int, spError* ); +spcEXTERN MatrixPtr spCreate( int, int, int* ); spcEXTERN void spDeleteRowAndCol( MatrixPtr, int, int ); spcEXTERN void spDestroy( MatrixPtr ); spcEXTERN int spElementCount( MatrixPtr ); spcEXTERN int spOriginalCount( MatrixPtr ); -spcEXTERN spError spErrorState( MatrixPtr ); +spcEXTERN int spError( MatrixPtr ); #ifdef EOF spcEXTERN void spErrorMessage( MatrixPtr, FILE*, char* ); #else @@ -326,18 +326,18 @@ spcEXTERN spError spErrorState( MatrixPtr ); #endif -spcEXTERN spError spFactor( MatrixPtr ); +spcEXTERN int spFactor( MatrixPtr ); spcEXTERN int spFileMatrix( MatrixPtr, char*, char*, int, int, int ); spcEXTERN int spFileStats( MatrixPtr, char*, char* ); spcEXTERN int spFillinCount( MatrixPtr ); spcEXTERN spElement *spFindElement( MatrixPtr, int, int ); -spcEXTERN spError spGetAdmittance( MatrixPtr, int, int, +spcEXTERN int spGetAdmittance( MatrixPtr, int, int, struct spTemplate* ); spcEXTERN spElement *spGetElement( MatrixPtr, int, int ); spcEXTERN spGenericPtr spGetInitInfo( spElement* ); -spcEXTERN spError spGetOnes( MatrixPtr, int, int, int, +spcEXTERN int spGetOnes( MatrixPtr, int, int, int, struct spTemplate* ); -spcEXTERN spError spGetQuad( MatrixPtr, int, int, int, int, +spcEXTERN int spGetQuad( MatrixPtr, int, int, int, int, struct spTemplate* ); spcEXTERN int spGetSize( MatrixPtr, int ); spcEXTERN int spInitialize( MatrixPtr, int (*pInit)(spElement *, spGenericPtr, int, int) ); @@ -345,7 +345,7 @@ spcEXTERN void spInstallInitInfo( spElement*, spGenericPtr ); spcEXTERN spREAL spLargestElement( MatrixPtr ); spcEXTERN void spMNA_Preorder( MatrixPtr ); spcEXTERN spREAL spNorm( MatrixPtr ); -spcEXTERN spError spOrderAndFactor( MatrixPtr, spREAL[], spREAL, +spcEXTERN int spOrderAndFactor( MatrixPtr, spREAL[], spREAL, spREAL, int ); spcEXTERN void spPartition( MatrixPtr, int ); spcEXTERN void spPrint( MatrixPtr, int, int, int ); diff --git a/src/maths/sparse/spAllocate.c b/src/maths/sparse/spAllocate.c index 57a051bbd..f20357f85 100644 --- a/src/maths/sparse/spAllocate.c +++ b/src/maths/sparse/spAllocate.c @@ -18,7 +18,7 @@ /* >>> User accessible functions contained in this file: * spCreate * spDestroy - * spErrorState + * spError * spWhereSingular * spGetSize * spSetReal @@ -92,7 +92,7 @@ char spcMatrixMustNotBeFactored[] = "Matrix must not be factored"; //static spError ReserveElements( MatrixPtr, int ); static void InitializeElementBlocks( MatrixPtr, int, int ); -static void RecordAllocation( MatrixPtr, void* ); +static void RecordAllocation( MatrixPtr, void * ); static void AllocateBlockOfAllocationList( MatrixPtr ); @@ -115,7 +115,7 @@ static void AllocateBlockOfAllocationList( MatrixPtr ); * Further note that if a matrix will be both real and complex, it must * be specified here as being complex. * \param pError - * Returns error flag, needed because function \a spErrorState() will + * Returns error flag, needed because function \a spError() will * not work correctly if \a spCreate() returns \a NULL. Possible errors * include \a spNO_MEMORY and \a spPANIC. */ @@ -130,7 +130,7 @@ MatrixPtr spCreate( int Size, int Complex, - spError *pError + int *pError ) { unsigned SizePlusOne; @@ -596,7 +596,7 @@ AllocationListPtr ListPtr; } /* Record allocation of space for allocation list on allocation list. */ - Matrix->TopOfAllocationList->AllocatedPtr = ListPtr; + Matrix->TopOfAllocationList->AllocatedPtr = (void *)ListPtr; Matrix->RecordsRemaining = ELEMENTS_PER_ALLOCATION; return; @@ -654,7 +654,11 @@ AllocationListPtr ListPtr, NextListPtr; ListPtr = Matrix->TopOfAllocationList; while (ListPtr != NULL) { NextListPtr = ListPtr->NextRecord; - SP_FREE( ListPtr->AllocatedPtr ); + if ((void *) ListPtr == ListPtr->AllocatedPtr) { + SP_FREE( ListPtr ); + } else { + SP_FREE( ListPtr->AllocatedPtr ); + } ListPtr = NextListPtr; } return; @@ -676,10 +680,10 @@ AllocationListPtr ListPtr, NextListPtr; * The pointer to the matrix for which the error status is desired. */ -spError -spErrorState( MatrixPtr Matrix ) +int +spError( MatrixPtr Matrix ) { -/* Begin `spErrorState'. */ +/* Begin `spError'. */ if (Matrix != NULL) { ASSERT_IS_SPARSE( Matrix ); diff --git a/src/maths/sparse/spFactor.c b/src/maths/sparse/spFactor.c index a91de02c8..028dd11ee 100644 --- a/src/maths/sparse/spFactor.c +++ b/src/maths/sparse/spFactor.c @@ -196,7 +196,7 @@ static void WriteStatus( MatrixPtr, int ); * */ -spError +int spOrderAndFactor( MatrixPtr Matrix, spREAL RHS[], @@ -338,7 +338,7 @@ Done: * \see spOrderAndFactor() */ -spError +int spFactor( MatrixPtr Matrix ) { #if REAL diff --git a/src/maths/sparse/spSMP.c b/src/maths/sparse/spSMP.c index 1f308a36c..743f86c49 100644 --- a/src/maths/sparse/spSMP.c +++ b/src/maths/sparse/spSMP.c @@ -122,7 +122,7 @@ int Row, int Col, double Value) { *spGetElement( Matrix, Row, Col ) = Value; - return spErrorState( Matrix ); + return spError( Matrix ); } /* @@ -311,7 +311,7 @@ SMPpreOrder( SMPmatrix *Matrix) { spMNA_Preorder( Matrix ); - return spErrorState( Matrix ); + return spError( Matrix ); } /* @@ -368,7 +368,7 @@ int *pExponent) #else spDeterminant( Matrix, pExponent, &(pMantissa->real) ); #endif - return spErrorState( Matrix ); + return spError( Matrix ); } /* @@ -454,7 +454,7 @@ SMPcDProd(SMPmatrix *Matrix, SPcomplex *pMantissa, int *pExponent) printf("Determinant 10->2: (%20g,%20g)^%d\n", pMantissa->real, pMantissa->imag, *pExponent); #endif - return spErrorState( Matrix ); + return spError( Matrix ); } @@ -542,7 +542,7 @@ SMPcZeroCol(SMPmatrix *Matrix, int Col) #endif } - return spErrorState( Matrix ); + return spError( Matrix ); } /* @@ -575,7 +575,7 @@ SMPcAddCol(SMPmatrix *Matrix, int Accum_Col, int Addend_Col) Addend = Addend->NextInCol; } - return spErrorState( Matrix ); + return spError( Matrix ); } /*