diff options
Diffstat (limited to 'src/misc/extra')
| -rw-r--r-- | src/misc/extra/extra.h | 5 | ||||
| -rw-r--r-- | src/misc/extra/extraUtilMemory.c | 21 | ||||
| -rw-r--r-- | src/misc/extra/extraUtilTruth.c | 6 |
3 files changed, 31 insertions, 1 deletions
diff --git a/src/misc/extra/extra.h b/src/misc/extra/extra.h index e02ec82a..6336f5ea 100644 --- a/src/misc/extra/extra.h +++ b/src/misc/extra/extra.h @@ -41,6 +41,10 @@ extern "C" { /* Nested includes */ /*---------------------------------------------------------------------------*/ +// this include should be the first one in the list +// it is used to catch memory leaks on Windows +#include "leaks.h" + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -463,6 +467,7 @@ extern unsigned Extra_TruthSemiCanonicize( unsigned * pInOut, unsigned * pAux, i (obj) ? ((type *) realloc((char *) obj, sizeof(type) * (num))) : \ ((type *) malloc(sizeof(type) * (num))) + extern long Extra_CpuTime(); extern int Extra_GetSoftDataLimit(); extern void Extra_UtilGetoptReset(); diff --git a/src/misc/extra/extraUtilMemory.c b/src/misc/extra/extraUtilMemory.c index c9137c56..768f86fa 100644 --- a/src/misc/extra/extraUtilMemory.c +++ b/src/misc/extra/extraUtilMemory.c @@ -73,6 +73,9 @@ struct Extra_MmStep_t_ Extra_MmFixed_t ** pMems; // memory managers: 2^1 words, 2^2 words, etc int nMapSize; // the size of the memory array Extra_MmFixed_t ** pMap; // maps the number of bytes into its memory manager + int nLargeChunksAlloc; // the maximum number of large memory chunks + int nLargeChunks; // the current number of large memory chunks + void ** pLargeChunks; // the allocated large memory chunks }; /*---------------------------------------------------------------------------*/ @@ -448,6 +451,7 @@ Extra_MmStep_t * Extra_MmStepStart( int nSteps ) Extra_MmStep_t * p; int i, k; p = ALLOC( Extra_MmStep_t, 1 ); + memset( p, 0, sizeof(Extra_MmStep_t) ); p->nMems = nSteps; // start the fixed memory managers p->pMems = ALLOC( Extra_MmFixed_t *, p->nMems ); @@ -483,6 +487,12 @@ void Extra_MmStepStop( Extra_MmStep_t * p, int fVerbose ) int i; for ( i = 0; i < p->nMems; i++ ) Extra_MmFixedStop( p->pMems[i], fVerbose ); +// if ( p->pLargeChunks ) +// { +// for ( i = 0; i < p->nLargeChunks; i++ ) +// free( p->pLargeChunks[i] ); +// free( p->pLargeChunks ); +// } free( p->pMems ); free( p->pMap ); free( p ); @@ -506,6 +516,17 @@ char * Extra_MmStepEntryFetch( Extra_MmStep_t * p, int nBytes ) if ( nBytes > p->nMapSize ) { // printf( "Allocating %d bytes.\n", nBytes ); +/* + if ( p->nLargeChunks == p->nLargeChunksAlloc ) + { + if ( p->nLargeChunksAlloc == 0 ) + p->nLargeChunksAlloc = 5; + p->nLargeChunksAlloc *= 2; + p->pLargeChunks = REALLOC( char *, p->pLargeChunks, p->nLargeChunksAlloc ); + } + p->pLargeChunks[ p->nLargeChunks++ ] = ALLOC( char, nBytes ); + return p->pLargeChunks[ p->nLargeChunks - 1 ]; +*/ return ALLOC( char, nBytes ); } return Extra_MmFixedEntryFetch( p->pMap[nBytes] ); diff --git a/src/misc/extra/extraUtilTruth.c b/src/misc/extra/extraUtilTruth.c index 2d6f307c..74308ab2 100644 --- a/src/misc/extra/extraUtilTruth.c +++ b/src/misc/extra/extraUtilTruth.c @@ -706,23 +706,27 @@ int Extra_TruthMinCofSuppOverlap( unsigned * pTruth, int nVars, int * pVarMin ) static unsigned uCofactor[16]; int i, ValueCur, ValueMin, VarMin; unsigned uSupp0, uSupp1; + int nVars0, nVars1; assert( nVars <= 9 ); ValueMin = 32; + VarMin = -1; for ( i = 0; i < nVars; i++ ) { // get negative cofactor Extra_TruthCopy( uCofactor, pTruth, nVars ); Extra_TruthCofactor0( uCofactor, nVars, i ); uSupp0 = Extra_TruthSupport( uCofactor, nVars ); + nVars0 = Extra_WordCountOnes( uSupp0 ); //Extra_PrintBinary( stdout, &uSupp0, 8 ); printf( "\n" ); // get positive cofactor Extra_TruthCopy( uCofactor, pTruth, nVars ); Extra_TruthCofactor1( uCofactor, nVars, i ); uSupp1 = Extra_TruthSupport( uCofactor, nVars ); + nVars1 = Extra_WordCountOnes( uSupp1 ); //Extra_PrintBinary( stdout, &uSupp1, 8 ); printf( "\n" ); // get the number of common vars ValueCur = Extra_WordCountOnes( uSupp0 & uSupp1 ); - if ( ValueMin > ValueCur ) + if ( ValueMin > ValueCur && nVars0 <= 5 && nVars1 <= 5 ) { ValueMin = ValueCur; VarMin = i; |
