00001
00019 #include "mvc.h"
00020
00024
00028
00040 Mvc_Cover_t * Mvc_CoverAlloc( Mvc_Manager_t * pMem, int nBits )
00041 {
00042 Mvc_Cover_t * p;
00043 int nBitsInUnsigned;
00044
00045 nBitsInUnsigned = 8 * sizeof(Mvc_CubeWord_t);
00046 #ifdef USE_SYSTEM_MEMORY_MANAGEMENT
00047 p = (Mvc_Cover_t *)malloc( sizeof(Mvc_Cover_t) );
00048 #else
00049 p = (Mvc_Cover_t *)Extra_MmFixedEntryFetch( pMem->pManC );
00050 #endif
00051 p->pMem = pMem;
00052 p->nBits = nBits;
00053 p->nWords = nBits / nBitsInUnsigned + (int)(nBits % nBitsInUnsigned > 0);
00054 p->nUnused = p->nWords * nBitsInUnsigned - p->nBits;
00055 p->lCubes.nItems = 0;
00056 p->lCubes.pHead = NULL;
00057 p->lCubes.pTail = NULL;
00058 p->nCubesAlloc = 0;
00059 p->pCubes = NULL;
00060 p->pMask = NULL;
00061 p->pLits = NULL;
00062 return p;
00063 }
00064
00076 Mvc_Cover_t * Mvc_CoverClone( Mvc_Cover_t * p )
00077 {
00078 Mvc_Cover_t * pCover;
00079 #ifdef USE_SYSTEM_MEMORY_MANAGEMENT
00080 pCover = (Mvc_Cover_t *)malloc( sizeof(Mvc_Cover_t) );
00081 #else
00082 pCover = (Mvc_Cover_t *)Extra_MmFixedEntryFetch( p->pMem->pManC );
00083 #endif
00084 pCover->pMem = p->pMem;
00085 pCover->nBits = p->nBits;
00086 pCover->nWords = p->nWords;
00087 pCover->nUnused = p->nUnused;
00088 pCover->lCubes.nItems = 0;
00089 pCover->lCubes.pHead = NULL;
00090 pCover->lCubes.pTail = NULL;
00091 pCover->nCubesAlloc = 0;
00092 pCover->pCubes = NULL;
00093 pCover->pMask = NULL;
00094 pCover->pLits = NULL;
00095 return pCover;
00096 }
00097
00109 Mvc_Cover_t * Mvc_CoverDup( Mvc_Cover_t * p )
00110 {
00111 Mvc_Cover_t * pCover;
00112 Mvc_Cube_t * pCube, * pCubeCopy;
00113
00114 pCover = Mvc_CoverClone( p );
00115
00116 Mvc_CoverForEachCube( p, pCube )
00117 {
00118 pCubeCopy = Mvc_CubeDup( p, pCube );
00119 Mvc_CoverAddCubeTail( pCover, pCubeCopy );
00120 }
00121 return pCover;
00122 }
00123
00135 void Mvc_CoverFree( Mvc_Cover_t * p )
00136 {
00137 Mvc_Cube_t * pCube, * pCube2;
00138
00139 Mvc_CoverForEachCubeSafe( p, pCube, pCube2 )
00140 Mvc_CubeFree( p, pCube );
00141
00142 Mvc_CubeFree( p, p->pMask );
00143 MEM_FREE( p->pMem, Mvc_Cube_t *, p->nCubesAlloc, p->pCubes );
00144 MEM_FREE( p->pMem, int, p->nBits, p->pLits );
00145
00146 #ifdef USE_SYSTEM_MEMORY_MANAGEMENT
00147 free( p );
00148 #else
00149 Extra_MmFixedEntryRecycle( p->pMem->pManC, (char *)p );
00150 #endif
00151 }
00152
00153
00165 void Mvc_CoverAllocateMask( Mvc_Cover_t * pCover )
00166 {
00167 if ( pCover->pMask == NULL )
00168 pCover->pMask = Mvc_CubeAlloc( pCover );
00169 }
00170
00182 void Mvc_CoverAllocateArrayLits( Mvc_Cover_t * pCover )
00183 {
00184 if ( pCover->pLits == NULL )
00185 pCover->pLits = MEM_ALLOC( pCover->pMem, int, pCover->nBits );
00186 }
00187
00199 void Mvc_CoverAllocateArrayCubes( Mvc_Cover_t * pCover )
00200 {
00201 if ( pCover->nCubesAlloc < pCover->lCubes.nItems )
00202 {
00203 if ( pCover->nCubesAlloc > 0 )
00204 MEM_FREE( pCover->pMem, Mvc_Cube_t *, pCover->nCubesAlloc, pCover->pCubes );
00205 pCover->nCubesAlloc = pCover->lCubes.nItems;
00206 pCover->pCubes = MEM_ALLOC( pCover->pMem, Mvc_Cube_t *, pCover->nCubesAlloc );
00207 }
00208 }
00209
00221 void Mvc_CoverDeallocateMask( Mvc_Cover_t * pCover )
00222 {
00223 Mvc_CubeFree( pCover, pCover->pMask );
00224 pCover->pMask = NULL;
00225 }
00226
00238 void Mvc_CoverDeallocateArrayLits( Mvc_Cover_t * pCover )
00239 {
00240 if ( pCover->pLits )
00241 {
00242 MEM_FREE( pCover->pMem, int, pCover->nBits, pCover->pLits );
00243 pCover->pLits = NULL;
00244 }
00245 }
00246
00250
00251