diff --git a/.github/workflows/build-posix-cmake.yml b/.github/workflows/build-posix-cmake.yml index def198107e..50f9ef902f 100644 --- a/.github/workflows/build-posix-cmake.yml +++ b/.github/workflows/build-posix-cmake.yml @@ -1,11 +1,15 @@ -on: [push] +name: Build Posix CMake + +on: + push: + pull_request: jobs: - build-posix: + build-posix-cmake: strategy: matrix: - os: [macos-11, ubuntu-latest] + os: [macos-latest, ubuntu-latest] use_namespace: [false, true] runs-on: ${{ matrix.os }} @@ -18,7 +22,7 @@ jobs: steps: - name: Git Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: submodules: recursive @@ -40,6 +44,10 @@ jobs: run: | cmake --build build + - name: Run Unit Tests + run: | + ctest --output-on-failure + - name: Test Executable run: | ./build/abc -c "r i10.aig; b; ps; b; rw -l; rw -lz; b; rw -lz; b; ps; cec" @@ -56,7 +64,7 @@ jobs: cp build/abc build/libabc.a staging/ - name: Upload pacakge artifact - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v4 with: - name: package + name: package-cmake-${{ matrix.os }}-${{ matrix.use_namespace }} path: staging/ diff --git a/.github/workflows/build-posix.yml b/.github/workflows/build-posix.yml index aa97aca20c..080c6e0453 100644 --- a/.github/workflows/build-posix.yml +++ b/.github/workflows/build-posix.yml @@ -1,4 +1,8 @@ -on: [push] +name: Build Posix + +on: + push: + pull_request: jobs: @@ -18,7 +22,7 @@ jobs: steps: - name: Git Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: submodules: recursive @@ -56,7 +60,7 @@ jobs: cp abc libabc.a staging/ - name: Upload pacakge artifact - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v4 with: - name: package + name: package-posix-${{ matrix.os }}-${{ matrix.use_namespace }} path: staging/ diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index 21cd1b26d5..2d08943648 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -1,4 +1,8 @@ -on: [push] +name: Build Windows + +on: + push: + pull_request: jobs: @@ -9,7 +13,7 @@ jobs: steps: - name: Git Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: submodules: recursive @@ -42,7 +46,7 @@ jobs: copy UpgradeLog.htm staging/ - name: Upload pacakge artifact - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v4 with: - name: package + name: package-windows path: staging/ diff --git a/src/aig/aig/aigCuts.c b/src/aig/aig/aigCuts.c index af4edcbb93..023afe64ad 100644 --- a/src/aig/aig/aigCuts.c +++ b/src/aig/aig/aigCuts.c @@ -64,7 +64,7 @@ Aig_ManCut_t * Aig_ManCutStart( Aig_Man_t * pMan, int nCutsMax, int nLeafMax, in // room for temporary truth tables if ( fTruth ) { - p->puTemp[0] = ABC_ALLOC( unsigned, 4 * p->nTruthWords ); + p->puTemp[0] = ABC_ALLOC( unsigned, 4 * (size_t)(p->nTruthWords )); p->puTemp[1] = p->puTemp[0] + p->nTruthWords; p->puTemp[2] = p->puTemp[1] + p->nTruthWords; p->puTemp[3] = p->puTemp[2] + p->nTruthWords; diff --git a/src/aig/aig/aigFanout.c b/src/aig/aig/aigFanout.c index d2fc1fe363..1daa6ba5cc 100644 --- a/src/aig/aig/aigFanout.c +++ b/src/aig/aig/aigFanout.c @@ -63,8 +63,8 @@ void Aig_ManFanoutStart( Aig_Man_t * p ) p->nFansAlloc = 2 * Aig_ManObjNumMax(p); if ( p->nFansAlloc < (1<<12) ) p->nFansAlloc = (1<<12); - p->pFanData = ABC_ALLOC( int, 5 * p->nFansAlloc ); - memset( p->pFanData, 0, sizeof(int) * 5 * p->nFansAlloc ); + p->pFanData = ABC_ALLOC( int, 5 * (size_t)(p->nFansAlloc )); + memset( p->pFanData, 0, sizeof(int) * 5 * (size_t)(p->nFansAlloc )); // add fanouts for all objects Aig_ManForEachObj( p, pObj, i ) { diff --git a/src/aig/aig/aigFrames.c b/src/aig/aig/aigFrames.c index 2d11104453..909c62f789 100644 --- a/src/aig/aig/aigFrames.c +++ b/src/aig/aig/aigFrames.c @@ -56,11 +56,12 @@ Aig_Man_t * Aig_ManFrames( Aig_Man_t * pAig, int nFs, int fInit, int fOuts, int int i, f; // create mapping for the frames nodes - pObjMap = ABC_ALLOC( Aig_Obj_t *, nFs * Aig_ManObjNumMax(pAig) ); - memset( pObjMap, 0, sizeof(Aig_Obj_t *) * nFs * Aig_ManObjNumMax(pAig) ); + size_t s = (size_t)(nFs) * (size_t)(Aig_ManObjNumMax(pAig)); + pObjMap = ABC_ALLOC( Aig_Obj_t *, s ); + memset( pObjMap, 0, sizeof(Aig_Obj_t *) * s ); // start the fraig package - pFrames = Aig_ManStart( Aig_ManObjNumMax(pAig) * nFs ); + pFrames = Aig_ManStart( s ); pFrames->pName = Abc_UtilStrsav( pAig->pName ); pFrames->pSpec = Abc_UtilStrsav( pAig->pSpec ); // map constant nodes diff --git a/src/aig/aig/aigMem.c b/src/aig/aig/aigMem.c index 7626b5fb8e..8eb13dce8c 100644 --- a/src/aig/aig/aigMem.c +++ b/src/aig/aig/aigMem.c @@ -31,20 +31,20 @@ struct Aig_MmFixed_t_ { // information about individual entries int nEntrySize; // the size of one entry - int nEntriesAlloc; // the total number of entries allocated - int nEntriesUsed; // the number of entries in use + size_t nEntriesAlloc; // the total number of entries allocated + size_t nEntriesUsed; // the number of entries in use int nEntriesMax; // the max number of entries in use char * pEntriesFree; // the linked list of free entries // this is where the memory is stored int nChunkSize; // the size of one chunk - int nChunksAlloc; // the maximum number of memory chunks - int nChunks; // the current number of memory chunks + size_t nChunksAlloc; // the maximum number of memory chunks + size_t nChunks; // the current number of memory chunks char ** pChunks; // the allocated memory // statistics - int nMemoryUsed; // memory used in the allocated entries - int nMemoryAlloc; // memory allocated + size_t nMemoryUsed; // memory used in the allocated entries + size_t nMemoryAlloc; // memory allocated }; struct Aig_MmFlex_t_ @@ -56,24 +56,24 @@ struct Aig_MmFlex_t_ // this is where the memory is stored int nChunkSize; // the size of one chunk - int nChunksAlloc; // the maximum number of memory chunks - int nChunks; // the current number of memory chunks + size_t nChunksAlloc; // the maximum number of memory chunks + size_t nChunks; // the current number of memory chunks char ** pChunks; // the allocated memory // statistics - int nMemoryUsed; // memory used in the allocated entries - int nMemoryAlloc; // memory allocated + size_t nMemoryUsed; // memory used in the allocated entries + size_t nMemoryAlloc; // memory allocated }; struct Aig_MmStep_t_ { int nMems; // the number of fixed memory managers employed Aig_MmFixed_t ** pMems; // memory managers: 2^1 words, 2^2 words, etc - int nMapSize; // the size of the memory array + size_t nMapSize; // the size of the memory array Aig_MmFixed_t ** pMap; // maps the number of bytes into its memory manager // additional memory chunks - int nChunksAlloc; // the maximum number of memory chunks - int nChunks; // the current number of memory chunks + size_t nChunksAlloc; // the maximum number of memory chunks + size_t nChunks; // the current number of memory chunks char ** pChunks; // the allocated memory }; @@ -172,7 +172,7 @@ char * Aig_MmFixedEntryFetch( Aig_MmFixed_t * p ) p->nChunksAlloc *= 2; p->pChunks = ABC_REALLOC( char *, p->pChunks, p->nChunksAlloc ); } - p->pEntriesFree = ABC_ALLOC( char, p->nEntrySize * p->nChunkSize ); + p->pEntriesFree = ABC_ALLOC( char, (size_t)(p->nEntrySize) * (size_t)(p->nChunkSize)); p->nMemoryAlloc += p->nEntrySize * p->nChunkSize; // transform these entries into a linked list pTemp = p->pEntriesFree; diff --git a/src/aig/aig/aigOrder.c b/src/aig/aig/aigOrder.c index 21bf8b8ee8..0d7d7e5202 100644 --- a/src/aig/aig/aigOrder.c +++ b/src/aig/aig/aigOrder.c @@ -52,8 +52,8 @@ void Aig_ManOrderStart( Aig_Man_t * p ) p->nOrderAlloc = 2 * Aig_ManObjNumMax(p); if ( p->nOrderAlloc < (1<<12) ) p->nOrderAlloc = (1<<12); - p->pOrderData = ABC_ALLOC( unsigned, 2 * p->nOrderAlloc ); - memset( p->pOrderData, 0xFF, sizeof(unsigned) * 2 * p->nOrderAlloc ); + p->pOrderData = ABC_ALLOC( unsigned, 2 * (size_t)(p->nOrderAlloc )); + memset( p->pOrderData, 0xFF, sizeof(unsigned) * 2 * (size_t)(p->nOrderAlloc )); // add the constant node p->pOrderData[0] = p->pOrderData[1] = 0; p->iPrev = p->iNext = 0; diff --git a/src/aig/aig/aigRet.c b/src/aig/aig/aigRet.c index 7712e8679d..dfdd28c53b 100644 --- a/src/aig/aig/aigRet.c +++ b/src/aig/aig/aigRet.c @@ -770,7 +770,7 @@ Aig_Man_t * Rtm_ManToAig( Rtm_Man_t * pRtm ) Rtm_Edg_t * pEdge; int i, k, m, Val, nLatches, * pLatches; // count latches and mark the first latch on each edge - pLatches = ABC_ALLOC( int, 2 * Vec_PtrSize(pRtm->vObjs) ); + pLatches = ABC_ALLOC( int, 2 * (size_t)(Vec_PtrSize(pRtm->vObjs)) ); nLatches = 0; Rtm_ManForEachObj( pRtm, pObjRtm, i ) Rtm_ObjForEachFaninEdge( pObjRtm, pEdge, k ) diff --git a/src/aig/gia/giaAigerExt.c b/src/aig/gia/giaAigerExt.c index 50c3588d94..4ecaa1d5e6 100644 --- a/src/aig/gia/giaAigerExt.c +++ b/src/aig/gia/giaAigerExt.c @@ -87,7 +87,7 @@ unsigned char * Gia_WriteEquivClassesInt( Gia_Man_t * p, int * pEquivSize ) Gia_ClassForEachObj( p, iRepr, iNode ) nItems++; } - pBuffer = ABC_ALLOC( unsigned char, sizeof(int) * (nItems + 10) ); + pBuffer = ABC_ALLOC( unsigned char, sizeof(int) * (size_t)(nItems + 10) ); // write constant class iPos = Gia_AigerWriteUnsignedBuffer( pBuffer, 4, Abc_Var2Lit(0, 1) ); iPrevNode = 0; @@ -176,7 +176,7 @@ unsigned char * Gia_AigerWriteMappingInt( Gia_Man_t * p, int * pMapSize ) nItems = 0; Gia_ManForEachLut( p, i ) nItems += 2 + Gia_ObjLutSize( p, i ); - pBuffer = ABC_ALLOC( unsigned char, sizeof(int) * (nItems + 1) ); + pBuffer = ABC_ALLOC( unsigned char, sizeof(int) * (size_t)(nItems + 1) ); // write non-constant classes iPrev = 0; Gia_ManForEachLut( p, i ) @@ -225,7 +225,7 @@ int * Gia_AigerReadMappingSimple( unsigned char ** ppPos, int nSize ) } Vec_Str_t * Gia_AigerWriteMappingSimple( Gia_Man_t * p ) { - unsigned char * pBuffer = ABC_ALLOC( unsigned char, 4*Vec_IntSize(p->vMapping) ); + unsigned char * pBuffer = ABC_ALLOC( unsigned char, 4*(size_t)Vec_IntSize(p->vMapping) ); memcpy( pBuffer, Vec_IntArray(p->vMapping), (size_t)4*Vec_IntSize(p->vMapping) ); assert( Vec_IntSize(p->vMapping) >= Gia_ManObjNum(p) ); return Vec_StrAllocArray( (char *)pBuffer, 4*Vec_IntSize(p->vMapping) ); @@ -274,7 +274,7 @@ Vec_Str_t * Gia_AigerWriteMappingDoc( Gia_Man_t * p ) nSize += Gia_ObjLutSize(p, i) + 2; LutSize = Abc_MaxInt( LutSize, Gia_ObjLutSize(p, i) ); } - pBuffer = ABC_ALLOC( unsigned char, 4 * nSize ); + pBuffer = ABC_ALLOC( unsigned char, 4 * (size_t)nSize ); Gia_AigerWriteInt( pBuffer + 4 * nSize2++, nLuts ); Gia_AigerWriteInt( pBuffer + 4 * nSize2++, LutSize ); Gia_ManForEachLut( p, i ) @@ -310,7 +310,7 @@ Vec_Int_t * Gia_AigerReadPacking( unsigned char ** ppPos, int nSize ) } Vec_Str_t * Gia_WritePacking( Vec_Int_t * vPacking ) { - unsigned char * pBuffer = ABC_ALLOC( unsigned char, 4*Vec_IntSize(vPacking) ); + unsigned char * pBuffer = ABC_ALLOC( unsigned char, 4*(size_t)Vec_IntSize(vPacking) ); int i, Entry, nSize = 0; Vec_IntForEachEntry( vPacking, Entry, i ) Gia_AigerWriteInt( pBuffer + 4 * nSize++, Entry ); diff --git a/src/aig/gia/giaEmbed.c b/src/aig/gia/giaEmbed.c index 28d28483f8..fd93754478 100644 --- a/src/aig/gia/giaEmbed.c +++ b/src/aig/gia/giaEmbed.c @@ -1170,7 +1170,7 @@ void Emb_ManComputeDimensions( Emb_Man_t * p, int nDims ) float ** Emb_ManMatrAlloc( int nDims ) { int i; - float ** pMatr = (float **)ABC_ALLOC( char, sizeof(float *) * nDims + sizeof(float) * nDims * nDims ); + float ** pMatr = (float **)ABC_ALLOC( char, sizeof(float *) * (size_t)nDims + sizeof(float) * (size_t)nDims * (size_t)nDims ); pMatr[0] = (float *)(pMatr + nDims); for ( i = 1; i < nDims; i++ ) pMatr[i] = pMatr[i-1] + nDims; @@ -1464,7 +1464,7 @@ void Emb_ManDerivePlacement( Emb_Man_t * p, int nSols ) pPerm1 = Gia_SortFloats( pY1, NULL, p->nObjs ); // average solutions and project them into square [0;GIA_PLACE_SIZE] x [0;GIA_PLACE_SIZE] - p->pPlacement = ABC_ALLOC( unsigned short, 2 * p->nObjs ); + p->pPlacement = ABC_ALLOC( unsigned short, 2 * (size_t)p->nObjs ); for ( k = 0; k < p->nObjs; k++ ) { p->pPlacement[2*pPerm0[k]+0] = (unsigned short)(int)(1.0 * k * GIA_PLACE_SIZE / p->nObjs); diff --git a/src/aig/gia/giaEra.c b/src/aig/gia/giaEra.c index b5b94cb513..62589a8c13 100644 --- a/src/aig/gia/giaEra.c +++ b/src/aig/gia/giaEra.c @@ -86,7 +86,7 @@ Gia_ManEra_t * Gia_ManEraCreate( Gia_Man_t * pAig ) p->pAig = pAig; p->nWordsSim = Abc_TruthWordNum( Gia_ManPiNum(pAig) ); p->nWordsDat = Abc_BitWordNum( Gia_ManRegNum(pAig) ); - p->pDataSim = ABC_ALLOC( unsigned, p->nWordsSim*Gia_ManObjNum(pAig) ); + p->pDataSim = ABC_ALLOC( unsigned, (size_t)p->nWordsSim*(size_t)Gia_ManObjNum(pAig) ); p->pMemory = Mem_FixedStart( sizeof(Gia_ObjEra_t) + sizeof(unsigned) * p->nWordsDat ); p->vStates = Vec_PtrAlloc( 100000 ); p->nBins = Abc_PrimeCudd( 100000 ); diff --git a/src/aig/gia/giaFanout.c b/src/aig/gia/giaFanout.c index fd58bfeb85..b0c9f5cc06 100644 --- a/src/aig/gia/giaFanout.c +++ b/src/aig/gia/giaFanout.c @@ -72,8 +72,8 @@ void Gia_ManFanoutStart( Gia_Man_t * p ) p->nFansAlloc = 2 * Gia_ManObjNum(p); if ( p->nFansAlloc < (1<<12) ) p->nFansAlloc = (1<<12); - p->pFanData = ABC_ALLOC( int, 5 * p->nFansAlloc ); - memset( p->pFanData, 0, sizeof(int) * 5 * p->nFansAlloc ); + p->pFanData = ABC_ALLOC( int, 5 * (size_t)p->nFansAlloc ); + memset( p->pFanData, 0, sizeof(int) * 5 * (size_t)p->nFansAlloc ); // add fanouts for all objects Gia_ManForEachObj( p, pObj, i ) { diff --git a/src/aig/gia/giaMem.c b/src/aig/gia/giaMem.c index d77ddfd511..2528aa5c61 100644 --- a/src/aig/gia/giaMem.c +++ b/src/aig/gia/giaMem.c @@ -172,7 +172,7 @@ char * Gia_MmFixedEntryFetch( Gia_MmFixed_t * p ) p->nChunksAlloc *= 2; p->pChunks = ABC_REALLOC( char *, p->pChunks, p->nChunksAlloc ); } - p->pEntriesFree = ABC_ALLOC( char, p->nEntrySize * p->nChunkSize ); + p->pEntriesFree = ABC_ALLOC( char, (size_t)p->nEntrySize * (size_t)p->nChunkSize ); p->nMemoryAlloc += p->nEntrySize * p->nChunkSize; // transform these entries into a linked list pTemp = p->pEntriesFree; diff --git a/src/aig/gia/giaMinLut2.c b/src/aig/gia/giaMinLut2.c index 85cae0d277..0b29d36d44 100644 --- a/src/aig/gia/giaMinLut2.c +++ b/src/aig/gia/giaMinLut2.c @@ -257,7 +257,7 @@ void Gia_ManPermStats( int nIns, int * pIPerm, int * pTried ) int Gia_ManPermuteTreeOne( word * pTruths, int nIns, int nOuts, int nWords, int fRandom, int * pIPermOut, int fVeryVerbose, int fVerbose ) { extern void Gia_ManDumpMuxes( Tree_Sto_t * p, char * pFileName, int * pIPerm ); - word * pStore = ABC_ALLOC( word, nIns*nOuts*nWords ); + word * pStore = ABC_ALLOC( word, (size_t)nIns*(size_t)nOuts*(size_t)nWords ); int pTried[TREE_MAX_VARS] = {0}; int pIPerm[TREE_MAX_VARS] = {0}; int v, r, Pos, nNodesPrev = -1, nNodesMin = 0, nNoChange = 0; @@ -475,7 +475,7 @@ word * Abc_TtMin( word * pF, word * pR, int nVars, Vec_Wrd_t * vMemory, Vec_Wrd_ word * Abc_TtMinArray( word * p, int nOuts, int nVars, int * pnNodes, int fVerbose ) { int o, i, nWords = Abc_TtWordNum(nVars); - word * pRes, * pResult = ABC_ALLOC( word, nOuts*nWords/2 ); + word * pRes, * pResult = ABC_ALLOC( word, (size_t)nOuts*(size_t)nWords/2 ); Vec_Wrd_t * vMemory = Vec_WrdAlloc( 100 ); Vec_Wrd_t * vNodes = Vec_WrdAlloc( 100 ); Vec_Wec_t * vNodes2 = Vec_WecStart( nVars+1 ); @@ -900,7 +900,7 @@ Gia_Man_t * Abc_TtGiaMinArray( word * p, int nVars, int nOuts, int * pnNodes, in { Gia_Man_t * pNew, * pTemp; int o, i, iLit, nWords = Abc_TtWordNum(nVars); - word * pRes, * pResult = ABC_ALLOC( word, nOuts*nWords/2 ); + word * pRes, * pResult = ABC_ALLOC( word, (size_t)nOuts*(size_t)nWords/2 ); Vec_Wrd_t * vMemory = Vec_WrdAlloc( 100 ); Vec_Wrd_t * vNodes = Vec_WrdAlloc( 100 ); Vec_Wec_t * vNodes2 = Vec_WecStart( nVars+1 ); @@ -1145,7 +1145,7 @@ Gia_Man_t * Gia_TryPermOpt2( word * pTruths, int nIns, int nOuts, int nWords, in abctime clk = Abc_Clock(); Gia_Man_t * pNew; word * pRes, * pTruthDup = Abc_TtDup( pTruths, nOuts*nWords, 0 ); - word * pTruthBest = ABC_ALLOC( word, nOuts*nWords/2 ); + word * pTruthBest = ABC_ALLOC( word, (size_t)nOuts*(size_t)nWords/2 ); int pIPermBest[TREE_MAX_VARS] = {0}; int pIPerm[TREE_MAX_VARS] = {0}; int r, rBest = -1, nNodes = -1, nNodesBest = ABC_INFINITY; @@ -1301,7 +1301,7 @@ void Abc_Tt6MinTest2( Gia_Man_t * p ) { int fVerbose = 0; int i, nWords = Abc_TtWordNum(Gia_ManCiNum(p)); - word * pTruth = ABC_ALLOC( word, 3*nWords ); + word * pTruth = ABC_ALLOC( word, 3*(size_t)nWords ); word * pRes = NULL, * pTruths[3] = { pTruth, pTruth+nWords, pTruth+2*nWords }; Vec_Int_t * vSupp = Vec_IntAlloc( 100 ); diff --git a/src/aig/gia/giaResub2.c b/src/aig/gia/giaResub2.c index 10c5a9e0e9..f71ef8df47 100644 --- a/src/aig/gia/giaResub2.c +++ b/src/aig/gia/giaResub2.c @@ -476,8 +476,8 @@ int Abc_ResubComputeWindow( int * pObjs, int nObjs, int nDivsMax, int nLevelIncr } int Abc_ResubComputeWindow2( int * pObjs, int nObjs, int nDivsMax, int nLevelIncrease, int fUseXor, int fUseZeroCost, int fDebug, int fVerbose, int ** ppArray, int * pnResubs ) { - *ppArray = ABC_ALLOC( int, 2*nObjs ); - memmove( *ppArray, pObjs, 2*nObjs * sizeof(int) ); + *ppArray = ABC_ALLOC( int, 2*(size_t)nObjs ); + memmove( *ppArray, pObjs, 2*(size_t)nObjs * sizeof(int) ); if ( pnResubs ) *pnResubs = 0; return nObjs; diff --git a/src/aig/gia/giaSim.c b/src/aig/gia/giaSim.c index ecad182f76..b7707aa192 100644 --- a/src/aig/gia/giaSim.c +++ b/src/aig/gia/giaSim.c @@ -221,9 +221,9 @@ Gia_ManSim_t * Gia_ManSimCreate( Gia_Man_t * pAig, Gia_ParSim_t * pPars ) p->pAig = Gia_ManFront( pAig ); p->pPars = pPars; p->nWords = pPars->nWords; - p->pDataSim = ABC_ALLOC( unsigned, p->nWords * p->pAig->nFront ); - p->pDataSimCis = ABC_ALLOC( unsigned, p->nWords * Gia_ManCiNum(p->pAig) ); - p->pDataSimCos = ABC_ALLOC( unsigned, p->nWords * Gia_ManCoNum(p->pAig) ); + p->pDataSim = ABC_ALLOC( unsigned, (size_t)p->nWords * (size_t)p->pAig->nFront ); + p->pDataSimCis = ABC_ALLOC( unsigned, (size_t)p->nWords * (size_t)Gia_ManCiNum(p->pAig) ); + p->pDataSimCos = ABC_ALLOC( unsigned, (size_t)p->nWords * (size_t)Gia_ManCoNum(p->pAig) ); if ( !p->pDataSim || !p->pDataSimCis || !p->pDataSimCos ) { Abc_Print( 1, "Simulator could not allocate %.2f GB for simulation info.\n", diff --git a/src/aig/gia/giaSimBase.c b/src/aig/gia/giaSimBase.c index 97335d3783..ca70869d69 100644 --- a/src/aig/gia/giaSimBase.c +++ b/src/aig/gia/giaSimBase.c @@ -294,7 +294,7 @@ word * Gia_ManDeriveFuncs( Gia_Man_t * p ) int nVars3 = Gia_ManCiNum(p) - nVars2; int nWords = Abc_Truth6WordNum( Gia_ManCiNum(p) ); int nWords2 = Abc_Truth6WordNum( nVars2 ); - word * pRes = ABC_ALLOC( word, Gia_ManCoNum(p) * nWords ); + word * pRes = ABC_ALLOC( word, (size_t)Gia_ManCoNum(p) * (size_t)nWords ); Vec_Wrd_t * vSims = Vec_WrdStart( nWords2 * Gia_ManObjNum(p) ); Vec_Ptr_t * vTruths = Vec_PtrAllocTruthTables( nVars2 ); Gia_Obj_t * pObj; int i, v, m; diff --git a/src/aig/gia/giaSwitch.c b/src/aig/gia/giaSwitch.c index 4722ef0f59..25ba4c529a 100644 --- a/src/aig/gia/giaSwitch.c +++ b/src/aig/gia/giaSwitch.c @@ -105,9 +105,9 @@ Gia_ManSwi_t * Gia_ManSwiCreate( Gia_Man_t * pAig, Gia_ParSwi_t * pPars ) p->pAig = Gia_ManFront( pAig ); p->pPars = pPars; p->nWords = pPars->nWords; - p->pDataSim = ABC_ALLOC( unsigned, p->nWords * p->pAig->nFront ); - p->pDataSimCis = ABC_ALLOC( unsigned, p->nWords * Gia_ManCiNum(p->pAig) ); - p->pDataSimCos = ABC_ALLOC( unsigned, p->nWords * Gia_ManCoNum(p->pAig) ); + p->pDataSim = ABC_ALLOC( unsigned, (size_t)p->nWords * (size_t)p->pAig->nFront ); + p->pDataSimCis = ABC_ALLOC( unsigned, (size_t)p->nWords * (size_t)Gia_ManCiNum(p->pAig) ); + p->pDataSimCos = ABC_ALLOC( unsigned, (size_t)p->nWords * (size_t)Gia_ManCoNum(p->pAig) ); p->pData1 = ABC_CALLOC( int, Gia_ManObjNum(pAig) ); return p; } diff --git a/src/aig/gia/giaTsim.c b/src/aig/gia/giaTsim.c index 7f93c5426d..4a35ee714e 100644 --- a/src/aig/gia/giaTsim.c +++ b/src/aig/gia/giaTsim.c @@ -84,9 +84,9 @@ Gia_ManTer_t * Gia_ManTerCreate( Gia_Man_t * pAig ) p = ABC_CALLOC( Gia_ManTer_t, 1 ); p->pAig = Gia_ManFront( pAig ); p->nIters = 300; - p->pDataSim = ABC_ALLOC( unsigned, Abc_BitWordNum(2*p->pAig->nFront) ); - p->pDataSimCis = ABC_ALLOC( unsigned, Abc_BitWordNum(2*Gia_ManCiNum(p->pAig)) ); - p->pDataSimCos = ABC_ALLOC( unsigned, Abc_BitWordNum(2*Gia_ManCoNum(p->pAig)) ); + p->pDataSim = ABC_ALLOC( unsigned, Abc_BitWordNum(2*(size_t)p->pAig->nFront) ); + p->pDataSimCis = ABC_ALLOC( unsigned, Abc_BitWordNum(2*(size_t)Gia_ManCiNum(p->pAig)) ); + p->pDataSimCos = ABC_ALLOC( unsigned, Abc_BitWordNum(2*(size_t)Gia_ManCoNum(p->pAig)) ); // allocate storage for terminary states p->nStateWords = Abc_BitWordNum( 2*Gia_ManRegNum(pAig) ); p->vStates = Vec_PtrAlloc( 1000 ); diff --git a/src/aig/ivy/ivyFastMap.c b/src/aig/ivy/ivyFastMap.c index b8322b3fd1..9a1a23d3f8 100644 --- a/src/aig/ivy/ivyFastMap.c +++ b/src/aig/ivy/ivyFastMap.c @@ -114,8 +114,8 @@ void Ivy_FastMapPerform( Ivy_Man_t * pAig, int nLimit, int fRecovery, int fVerbo pMan->nLimit = nLimit; pMan->nObjs = Ivy_ManObjIdMax(pAig) + 1; pMan->nSize = sizeof(Ivy_Supp_t) + nLimit * sizeof(int); - pMan->pMem = (char *)ABC_ALLOC( char, pMan->nObjs * pMan->nSize ); - memset( pMan->pMem, 0, pMan->nObjs * pMan->nSize ); + pMan->pMem = (char *)ABC_ALLOC( char, (size_t)pMan->nObjs * (size_t)pMan->nSize ); + memset( pMan->pMem, 0, (size_t)pMan->nObjs * (size_t)pMan->nSize ); pMan->vLuts = Vec_VecAlloc( 100 ); pAig->pData = pMan; clk = Abc_Clock(); diff --git a/src/aig/ivy/ivyFraig.c b/src/aig/ivy/ivyFraig.c index 0bf05ee886..837c8505c2 100644 --- a/src/aig/ivy/ivyFraig.c +++ b/src/aig/ivy/ivyFraig.c @@ -571,7 +571,7 @@ Ivy_FraigMan_t * Ivy_FraigStart( Ivy_Man_t * pManAig, Ivy_FraigParams_t * pParam p->nSimWords = pParams->nSimWords; // p->pSimWords = ABC_ALLOC( unsigned, Ivy_ManObjNum(pManAig) * p->nSimWords ); EntrySize = sizeof(Ivy_FraigSim_t) + sizeof(unsigned) * p->nSimWords; - p->pSimWords = (char *)ABC_ALLOC( char, Ivy_ManObjNum(pManAig) * EntrySize ); + p->pSimWords = (char *)ABC_ALLOC( char, (size_t)Ivy_ManObjNum(pManAig) * (size_t)EntrySize ); memset( p->pSimWords, 0, (size_t)EntrySize ); k = 0; Ivy_ManForEachObj( pManAig, pObj, i ) @@ -600,7 +600,7 @@ Ivy_FraigMan_t * Ivy_FraigStart( Ivy_Man_t * pManAig, Ivy_FraigParams_t * pParam // allocate storage for sim pattern p->nPatWords = Ivy_BitWordNum( Ivy_ManPiNum(pManAig) ); p->pPatWords = ABC_ALLOC( unsigned, p->nPatWords ); - p->pPatScores = ABC_ALLOC( int, 32 * p->nSimWords ); + p->pPatScores = ABC_ALLOC( int, 32 * (size_t)p->nSimWords ); p->vPiVars = Vec_PtrAlloc( 100 ); // set random number generator srand( 0xABCABC ); diff --git a/src/aig/saig/saigPhase.c b/src/aig/saig/saigPhase.c index e7a586fe05..fc3def507a 100644 --- a/src/aig/saig/saigPhase.c +++ b/src/aig/saig/saigPhase.c @@ -756,8 +756,8 @@ Aig_Man_t * Saig_ManPerformAbstraction( Saig_Tsim_t * pTsi, int nFrames, int fVe assert( Vec_IntSize(pTsi->vNonXRegs) > 0 ); // create mapping for the frames nodes - pObjMap = ABC_ALLOC( Aig_Obj_t *, nFrames * Aig_ManObjNumMax(pAig) ); - memset( pObjMap, 0, sizeof(Aig_Obj_t *) * nFrames * Aig_ManObjNumMax(pAig) ); + pObjMap = ABC_ALLOC( Aig_Obj_t *, (size_t)nFrames * (size_t)Aig_ManObjNumMax(pAig) ); + memset( pObjMap, 0, sizeof(Aig_Obj_t *) * (size_t)nFrames * (size_t)Aig_ManObjNumMax(pAig) ); // start the fraig package pFrames = Aig_ManStart( Aig_ManObjNumMax(pAig) * nFrames ); diff --git a/src/aig/saig/saigSimFast.c b/src/aig/saig/saigSimFast.c index fef8367533..9fa37f333c 100644 --- a/src/aig/saig/saigSimFast.c +++ b/src/aig/saig/saigSimFast.c @@ -113,7 +113,7 @@ Faig_Man_t * Faig_ManAlloc( Aig_Man_t * pAig ) int nWords; // assert( Faig_ManIsCorrect(pAig) ); nWords = 2 * Aig_ManNodeNum(pAig) + Aig_ManCoNum(pAig); - p = (Faig_Man_t *)ABC_ALLOC( char, sizeof(Faig_Man_t) + sizeof(int) * nWords ); + p = (Faig_Man_t *)ABC_ALLOC( char, sizeof(Faig_Man_t) + sizeof(int) * (size_t)nWords ); //printf( "Allocating %7.2f MB.\n", 1.0 * (sizeof(Faig_Man_t) + sizeof(int) * nWords)/(1<<20) ); memset( p, 0, sizeof(Faig_Man_t) ); p->nPis = Aig_ManCiNum(pAig) - Aig_ManRegNum(pAig); diff --git a/src/aig/saig/saigSimMv.c b/src/aig/saig/saigSimMv.c index 3621cdd3b3..270d924920 100644 --- a/src/aig/saig/saigSimMv.c +++ b/src/aig/saig/saigSimMv.c @@ -223,7 +223,7 @@ Saig_MvMan_t * Saig_MvManStart( Aig_Man_t * pAig, int nFramesSatur ) Vec_PtrPush( p->vStates, NULL ); p->pRegsUndef = ABC_CALLOC( int, p->nFlops ); p->pRegsValues = ABC_ALLOC( int *, p->nFlops ); - p->pRegsValues[0] = ABC_ALLOC( int, p->nValuesMax * p->nFlops ); + p->pRegsValues[0] = ABC_ALLOC( int, (size_t)p->nValuesMax * (size_t)p->nFlops ); for ( i = 1; i < p->nFlops; i++ ) p->pRegsValues[i] = p->pRegsValues[i-1] + p->nValuesMax; p->nRegsValues = ABC_CALLOC( int, p->nFlops ); diff --git a/src/aig/saig/saigSwitch.c b/src/aig/saig/saigSwitch.c index b18ca8035b..29b1ff1cda 100644 --- a/src/aig/saig/saigSwitch.c +++ b/src/aig/saig/saigSwitch.c @@ -361,7 +361,7 @@ struct Aig_CMan_t_ Aig_CMan_t * Aig_CManStart( int nIns, int nNodes, int nOuts ) { Aig_CMan_t * p; - p = (Aig_CMan_t *)ABC_ALLOC( char, sizeof(Aig_CMan_t) + 2*(2*nNodes + nOuts) ); + p = (Aig_CMan_t *)ABC_ALLOC( char, sizeof(Aig_CMan_t) + 2*(2*(size_t)nNodes + (size_t)nOuts) ); memset( p, 0, sizeof(Aig_CMan_t) ); // set parameters p->nIns = nIns; diff --git a/src/base/abc/abcFanio.c b/src/base/abc/abcFanio.c index 519debb1f8..5b8b432da3 100644 --- a/src/base/abc/abcFanio.c +++ b/src/base/abc/abcFanio.c @@ -54,7 +54,7 @@ static inline void Vec_IntPushMem( Mem_Step_t * pMemMan, Vec_Int_t * p, int Entr if ( pMemMan ) pArray = (int *)Mem_StepEntryFetch( pMemMan, p->nCap * 8 ); else - pArray = ABC_ALLOC( int, p->nCap * 2 ); + pArray = ABC_ALLOC( int, (size_t)p->nCap * 2 ); if ( p->pArray ) { for ( i = 0; i < p->nSize; i++ ) diff --git a/src/base/abci/abcAttach.c b/src/base/abci/abcAttach.c index f24e1a72d9..7fb2f587fb 100644 --- a/src/base/abci/abcAttach.c +++ b/src/base/abci/abcAttach.c @@ -84,7 +84,7 @@ int Abc_NtkAttach( Abc_Ntk_t * pNtk ) // derive the gate truth tables puTruthGates = ABC_ALLOC( unsigned *, nGates ); - puTruthGates[0] = ABC_ALLOC( unsigned, 2 * nGates ); + puTruthGates[0] = ABC_ALLOC( unsigned, 2 * (size_t)nGates ); for ( i = 1; i < nGates; i++ ) puTruthGates[i] = puTruthGates[i-1] + 2; for ( i = 0; i < nGates; i++ ) diff --git a/src/base/abci/abcOdc.c b/src/base/abci/abcOdc.c index 23915b1e82..4d069f1579 100644 --- a/src/base/abci/abcOdc.c +++ b/src/base/abci/abcOdc.c @@ -187,7 +187,7 @@ Odc_Man_t * Abc_NtkDontCareAlloc( int nVarsMax, int nLevels, int fVerbose, int f // internal AIG package // allocate room for objects p->nObjsAlloc = ABC_DC_MAX_NODES; - p->pObjs = ABC_ALLOC( Odc_Obj_t, p->nObjsAlloc * sizeof(Odc_Obj_t) ); + p->pObjs = ABC_ALLOC( Odc_Obj_t, (size_t)p->nObjsAlloc * sizeof(Odc_Obj_t) ); p->nPis = nVarsMax + 32; p->nObjs = 1 + p->nPis; memset( p->pObjs, 0, p->nObjs * sizeof(Odc_Obj_t) ); @@ -196,8 +196,8 @@ Odc_Man_t * Abc_NtkDontCareAlloc( int nVarsMax, int nLevels, int fVerbose, int f p->pObjs[1 + p->nVarsMax + i].uMask = (1 << i); // allocate hash table p->nTableSize = p->nObjsAlloc/3 + 1; - p->pTable = ABC_ALLOC( Odc_Lit_t, p->nTableSize * sizeof(Odc_Lit_t) ); - memset( p->pTable, 0, p->nTableSize * sizeof(Odc_Lit_t) ); + p->pTable = ABC_ALLOC( Odc_Lit_t, (size_t)p->nTableSize * sizeof(Odc_Lit_t) ); + memset( p->pTable, 0, (size_t)p->nTableSize * sizeof(Odc_Lit_t) ); p->vUsedSpots = Vec_IntAlloc( 1000 ); // truth tables diff --git a/src/base/abci/abcPart.c b/src/base/abci/abcPart.c index fc654bc92b..63d7694220 100644 --- a/src/base/abci/abcPart.c +++ b/src/base/abci/abcPart.c @@ -1124,9 +1124,10 @@ Abc_Ntk_t * Abc_NtkFraigPartitioned( Vec_Ptr_t * vStore, void * pParams ) Abc_NtkConvertCos( pNtk2, vOne, vOnePtr ); Abc_NtkAppendToCone( pNtkAig, pNtk2, vOnePtr ); } - printf( "Fraiging part %4d (out of %4d) PI = %5d. PO = %5d. And = %6d. Lev = %4d.\r", - i+1, Vec_PtrSize(vParts), Abc_NtkPiNum(pNtkAig), Abc_NtkPoNum(pNtkAig), - Abc_NtkNodeNum(pNtkAig), Abc_AigLevel(pNtkAig) ); + if (!Abc_FrameIsBatchMode()) + printf( "Fraiging part %4d (out of %4d) PI = %5d. PO = %5d. And = %6d. Lev = %4d.\r", + i+1, Vec_PtrSize(vParts), Abc_NtkPiNum(pNtkAig), Abc_NtkPoNum(pNtkAig), + Abc_NtkNodeNum(pNtkAig), Abc_AigLevel(pNtkAig) ); // fraig the partition pNtkFraig = Abc_NtkFraig( pNtkAig, pParams, 1, 0 ); Vec_PtrPush( vFraigs, pNtkFraig ); diff --git a/src/base/abci/abcResub.c b/src/base/abci/abcResub.c index 85f8a4b4c3..60cf07dab7 100644 --- a/src/base/abci/abcResub.c +++ b/src/base/abci/abcResub.c @@ -303,8 +303,8 @@ Abc_ManRes_t * Abc_ManResubStart( int nLeavesMax, int nDivsMax ) // allocate simulation info p->nBits = (1 << p->nLeavesMax); p->nWords = (p->nBits <= 32)? 1 : (p->nBits / 32); - p->pInfo = ABC_ALLOC( unsigned, p->nWords * (p->nDivsMax + 1) ); - memset( p->pInfo, 0, sizeof(unsigned) * p->nWords * p->nLeavesMax ); + p->pInfo = ABC_ALLOC( unsigned, (size_t)p->nWords * ((size_t)p->nDivsMax + 1) ); + memset( p->pInfo, 0, sizeof(unsigned) * (size_t)p->nWords * p->nLeavesMax ); p->vSims = Vec_PtrAlloc( p->nDivsMax ); for ( i = 0; i < p->nDivsMax; i++ ) Vec_PtrPush( p->vSims, p->pInfo + i * p->nWords ); diff --git a/src/base/abci/abcSpeedup.c b/src/base/abci/abcSpeedup.c index a4a627ba80..fd9afb72ef 100644 --- a/src/base/abci/abcSpeedup.c +++ b/src/base/abci/abcSpeedup.c @@ -120,7 +120,7 @@ float Abc_NtkDelayTraceLut( Abc_Ntk_t * pNtk, int fUseLutLib ) // initialize the arrival times ABC_FREE( pNtk->pLutTimes ); - pNtk->pLutTimes = ABC_ALLOC( float, 3 * Abc_NtkObjNumMax(pNtk) ); + pNtk->pLutTimes = ABC_ALLOC( float, 3 * (size_t)Abc_NtkObjNumMax(pNtk) ); for ( i = 0; i < Abc_NtkObjNumMax(pNtk); i++ ) { pNtk->pLutTimes[3*i+0] = pNtk->pLutTimes[3*i+2] = 0; diff --git a/src/base/abci/abcVerify.c b/src/base/abci/abcVerify.c index f3e86746c1..efc57a76d2 100644 --- a/src/base/abci/abcVerify.c +++ b/src/base/abci/abcVerify.c @@ -671,8 +671,8 @@ int Abc_NtkSecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nSeconds, int nFr ***********************************************************************/ int * Abc_NtkVerifyGetCleanModel( Abc_Ntk_t * pNtk, int nFrames ) { - int * pModel = ABC_ALLOC( int, Abc_NtkCiNum(pNtk) * nFrames ); - memset( pModel, 0, sizeof(int) * Abc_NtkCiNum(pNtk) * nFrames ); + int * pModel = ABC_ALLOC( int, (size_t)Abc_NtkCiNum(pNtk) * nFrames ); + memset( pModel, 0, sizeof(int) * (size_t)Abc_NtkCiNum(pNtk) * nFrames ); return pModel; } diff --git a/src/bdd/cas/casDec.c b/src/bdd/cas/casDec.c index f00bc46b46..25eb2cdb0c 100644 --- a/src/bdd/cas/casDec.c +++ b/src/bdd/cas/casDec.c @@ -196,9 +196,9 @@ int CreateDecomposedNetwork( DdManager * dd, DdNode * aFunc, char ** pNames, int // there should be as many columns, codes, and nodes, as there are columns on this level - p->pbCols = (DdNode **) ABC_ALLOC( char, p->nCols * sizeof(DdNode *) ); - p->pbCodes = (DdNode **) ABC_ALLOC( char, p->nCols * sizeof(DdNode *) ); - p->paNodes = (DdNode **) ABC_ALLOC( char, p->nCols * sizeof(DdNode *) ); + p->pbCols = (DdNode **) ABC_ALLOC( char, (size_t)p->nCols * sizeof(DdNode *) ); + p->pbCodes = (DdNode **) ABC_ALLOC( char, (size_t)p->nCols * sizeof(DdNode *) ); + p->paNodes = (DdNode **) ABC_ALLOC( char, (size_t)p->nCols * sizeof(DdNode *) ); pLuts[nLuts] = p; nLuts++; @@ -318,7 +318,7 @@ printf( "Stage %3d: In = %3d InP = %3d Cols = %5d Multi = %2d Simple = %2d DdNode ** pbTemp; int k, v; - pbTemp = (DdNode **) ABC_ALLOC( char, p->nCols * sizeof(DdNode *) ); + pbTemp = (DdNode **) ABC_ALLOC( char, (size_t)p->nCols * sizeof(DdNode *) ); // create the identical permutation for ( v = 0; v < dd->size; v++ ) diff --git a/src/bdd/cudd/cuddEssent.c b/src/bdd/cudd/cuddEssent.c index fb6f327560..6e1666b612 100644 --- a/src/bdd/cudd/cuddEssent.c +++ b/src/bdd/cudd/cuddEssent.c @@ -982,7 +982,7 @@ computeClauses( /* Merge inherited and non-inherited clauses. Now that we know the ** total number, we allocate the arrays, and we fill them bottom-up ** to restore the proper ordering. */ - Vcv = ABC_ALLOC(DdHalfWord, 2*(cv+1)); + Vcv = ABC_ALLOC(DdHalfWord, 2*(size_t)(cv+1)); if (Vcv == NULL) goto cleanup; if (cv > 0) { Vcp = bitVectorAlloc(2*cv); diff --git a/src/bdd/cudd/cuddExact.c b/src/bdd/cudd/cuddExact.c index 80c415572a..a89280e2d5 100644 --- a/src/bdd/cudd/cuddExact.c +++ b/src/bdd/cudd/cuddExact.c @@ -458,7 +458,7 @@ getMatrix( if (cols*rows == 0) return(NULL); matrix = ABC_ALLOC(DdHalfWord *, rows); if (matrix == NULL) return(NULL); - matrix[0] = ABC_ALLOC(DdHalfWord, cols*rows); + matrix[0] = ABC_ALLOC(DdHalfWord, (size_t)cols*(size_t)rows); if (matrix[0] == NULL) { ABC_FREE(matrix); return(NULL); diff --git a/src/bdd/cudd/cuddGenetic.c b/src/bdd/cudd/cuddGenetic.c index 46194bfe99..f8f15b032b 100644 --- a/src/bdd/cudd/cuddGenetic.c +++ b/src/bdd/cudd/cuddGenetic.c @@ -209,7 +209,7 @@ cuddGa( if (popsize < 4) popsize = 4; /* enforce minimum population size */ /* Allocate population table. */ - storedd = ABC_ALLOC(int,(popsize+2)*(numvars+1)); + storedd = ABC_ALLOC(int,(size_t)(popsize+2)*(size_t)(numvars+1)); if (storedd == NULL) { table->errorCode = CUDD_MEMORY_OUT; return(0); diff --git a/src/bdd/cudd/cuddLCache.c b/src/bdd/cudd/cuddLCache.c index 1c3330ca18..037284553e 100644 --- a/src/bdd/cudd/cuddLCache.c +++ b/src/bdd/cudd/cuddLCache.c @@ -203,7 +203,7 @@ cuddLocalCacheInit( logSize = cuddComputeFloorLog2(ddMax(cacheSize,manager->slots/2)); cacheSize = 1 << logSize; cache->item = (DdLocalCacheItem *) - ABC_ALLOC(char, cacheSize * cache->itemsize); + ABC_ALLOC(char, (size_t)cacheSize * cache->itemsize); if (cache->item == NULL) { manager->errorCode = CUDD_MEMORY_OUT; ABC_FREE(cache); @@ -1123,7 +1123,7 @@ cuddLocalCacheResize( saveHandler = MMoutOfMemory; MMoutOfMemory = Cudd_OutOfMem; cache->item = item = - (DdLocalCacheItem *) ABC_ALLOC(char, slots * cache->itemsize); + (DdLocalCacheItem *) ABC_ALLOC(char, (size_t)slots * cache->itemsize); MMoutOfMemory = saveHandler; /* If we fail to allocate the new table we just give up. */ if (item == NULL) { @@ -1406,7 +1406,7 @@ cuddHashTableAlloc( if (hash->nextFree == NULL) { saveHandler = MMoutOfMemory; MMoutOfMemory = Cudd_OutOfMem; - mem = (DdHashItem **) ABC_ALLOC(char,(DD_MEM_CHUNK+1) * itemsize); + mem = (DdHashItem **) ABC_ALLOC(char,(size_t)(DD_MEM_CHUNK+1) * itemsize); MMoutOfMemory = saveHandler; #ifdef __osf__ #pragma pointer_size restore @@ -1428,7 +1428,7 @@ cuddHashTableAlloc( #pragma pointer_size save #pragma pointer_size short #endif - mem = (DdHashItem **) ABC_ALLOC(char,(DD_MEM_CHUNK+1) * itemsize); + mem = (DdHashItem **) ABC_ALLOC(char,(size_t)(DD_MEM_CHUNK+1) * itemsize); #ifdef __osf__ #pragma pointer_size restore #endif diff --git a/src/bdd/dsd/dsdMan.c b/src/bdd/dsd/dsdMan.c index 1490fcf370..771aff534c 100644 --- a/src/bdd/dsd/dsdMan.c +++ b/src/bdd/dsd/dsdMan.c @@ -59,8 +59,8 @@ Dsd_Manager_t * Dsd_ManagerStart( DdManager * dd, int nSuppMax, int fVerbose ) dMan->fVerbose = fVerbose; dMan->nRoots = 0; dMan->nRootsAlloc = 50; - dMan->pRoots = (Dsd_Node_t **) ABC_ALLOC( char, dMan->nRootsAlloc * sizeof(Dsd_Node_t *) ); - dMan->pInputs = (Dsd_Node_t **) ABC_ALLOC( char, dMan->nInputs * sizeof(Dsd_Node_t *) ); + dMan->pRoots = (Dsd_Node_t **) ABC_ALLOC( char, (size_t)dMan->nRootsAlloc * sizeof(Dsd_Node_t *) ); + dMan->pInputs = (Dsd_Node_t **) ABC_ALLOC( char, (size_t)dMan->nInputs * sizeof(Dsd_Node_t *) ); // create the primary inputs and insert them into the table dMan->Table = st__init_table( st__ptrcmp, st__ptrhash); diff --git a/src/bdd/dsd/dsdProc.c b/src/bdd/dsd/dsdProc.c index 8c775e8b94..55cdfa9568 100644 --- a/src/bdd/dsd/dsdProc.c +++ b/src/bdd/dsd/dsdProc.c @@ -134,7 +134,7 @@ s_Loops2Useless = 0; if ( pDsdMan->nRootsAlloc > 0 ) ABC_FREE( pDsdMan->pRoots ); pDsdMan->nRootsAlloc = nFuncs; - pDsdMan->pRoots = (Dsd_Node_t **) ABC_ALLOC( char, pDsdMan->nRootsAlloc * sizeof(Dsd_Node_t *) ); + pDsdMan->pRoots = (Dsd_Node_t **) ABC_ALLOC( char, (size_t)pDsdMan->nRootsAlloc * sizeof(Dsd_Node_t *) ); } if ( pDsdMan->fVerbose ) diff --git a/src/bdd/dsd/dsdTree.c b/src/bdd/dsd/dsdTree.c index 9b9dd21210..9d6327d6f4 100644 --- a/src/bdd/dsd/dsdTree.c +++ b/src/bdd/dsd/dsdTree.c @@ -67,7 +67,7 @@ Dsd_Node_t * Dsd_TreeNodeCreate( int Type, int nDecs, int BlockNum ) p->nDecs = nDecs; // the number of decompositions if ( p->nDecs ) { - p->pDecs = (Dsd_Node_t **) ABC_ALLOC( char, p->nDecs * sizeof(Dsd_Node_t *) ); + p->pDecs = (Dsd_Node_t **) ABC_ALLOC( char, (size_t)p->nDecs * sizeof(Dsd_Node_t *) ); p->pDecs[0] = NULL; } return p; diff --git a/src/bdd/extrab/extraBddCas.c b/src/bdd/extrab/extraBddCas.c index 024e446267..879d2202c4 100644 --- a/src/bdd/extrab/extraBddCas.c +++ b/src/bdd/extrab/extraBddCas.c @@ -229,7 +229,7 @@ Extra_bddEncodingNonStrict( // s_EncSearchTime += Abc_Clock() - clk; // allocate the temporary storage for the columns - s_pbTemp = (DdNode **)ABC_ALLOC( char, nColumns * sizeof(DdNode *) ); + s_pbTemp = (DdNode **)ABC_ALLOC( char, (size_t)nColumns * sizeof(DdNode *) ); // clk = Abc_Clock(); bResult = CreateTheCodes_rec( dd, bEncoded, 0, pCVars ); Cudd_Ref( bResult ); diff --git a/src/bdd/extrab/extraBddSymm.c b/src/bdd/extrab/extraBddSymm.c index 9dd2c8e553..658a204eba 100644 --- a/src/bdd/extrab/extraBddSymm.c +++ b/src/bdd/extrab/extraBddSymm.c @@ -215,8 +215,8 @@ Extra_SymmInfo_t * Extra_SymmPairsAllocate( int nVars ) p->nVars = nVars; p->pVars = ABC_ALLOC( int, nVars ); p->pSymms = ABC_ALLOC( char *, nVars ); - p->pSymms[0] = ABC_ALLOC( char , nVars * nVars ); - memset( p->pSymms[0], 0, nVars * nVars * sizeof(char) ); + p->pSymms[0] = ABC_ALLOC( char , (size_t)nVars * (size_t)nVars ); + memset( p->pSymms[0], 0, (size_t)nVars * (size_t)nVars * sizeof(char) ); for ( i = 1; i < nVars; i++ ) p->pSymms[i] = p->pSymms[i-1] + nVars; diff --git a/src/bool/bdc/bdcCore.c b/src/bool/bdc/bdcCore.c index cce0e3062b..671d7cb988 100644 --- a/src/bool/bdc/bdcCore.c +++ b/src/bool/bdc/bdcCore.c @@ -87,7 +87,7 @@ Bdc_Man_t * Bdc_ManAlloc( Bdc_Par_t * pPars ) p->vSpots = Vec_IntAlloc( 256 ); // truth tables p->vTruths = Vec_PtrAllocTruthTables( p->pPars->nVarsMax ); - p->puTemp1 = ABC_ALLOC( unsigned, 4 * p->nWords ); + p->puTemp1 = ABC_ALLOC( unsigned, 4 * (size_t)p->nWords ); p->puTemp2 = p->puTemp1 + p->nWords; p->puTemp3 = p->puTemp2 + p->nWords; p->puTemp4 = p->puTemp3 + p->nWords; diff --git a/src/bool/kit/kitDsd.c b/src/bool/kit/kitDsd.c index cd02db673f..254769b00c 100644 --- a/src/bool/kit/kitDsd.c +++ b/src/bool/kit/kitDsd.c @@ -146,7 +146,7 @@ Kit_DsdNtk_t * Kit_DsdNtkAlloc( int nVars ) pNtk->pNodes = ABC_ALLOC( Kit_DsdObj_t *, nVars+1 ); pNtk->nVars = nVars; pNtk->nNodesAlloc = nVars+1; - pNtk->pMem = ABC_ALLOC( unsigned, 6 * Kit_TruthWordNum(nVars) ); + pNtk->pMem = ABC_ALLOC( unsigned, 6 * (size_t)Kit_TruthWordNum(nVars) ); return pNtk; } @@ -2695,7 +2695,7 @@ int Kit_DsdCofactoring( unsigned * pTruth, int nVars, int * pCofVars, int nLimit // allocate storage for cofactors nMemSize = Kit_TruthWordNum(nVars); - ppCofs[0][0] = ABC_ALLOC( unsigned, 80 * nMemSize ); + ppCofs[0][0] = ABC_ALLOC( unsigned, 80 * (size_t)nMemSize ); nSize = 0; for ( i = 0; i < 5; i++ ) for ( k = 0; k < 16; k++ ) @@ -2820,7 +2820,7 @@ void Kit_DsdPrintCofactors( unsigned * pTruth, int nVars, int nCofLevel, int fVe // allocate storage for cofactors nMemSize = Kit_TruthWordNum(nVars); - ppCofs[0][0] = ABC_ALLOC( unsigned, 80 * nMemSize ); + ppCofs[0][0] = ABC_ALLOC( unsigned, 80 *(size_t) nMemSize ); nSize = 0; for ( i = 0; i < 5; i++ ) for ( k = 0; k < 16; k++ ) diff --git a/src/bool/kit/kitTruth.c b/src/bool/kit/kitTruth.c index dbf013fec2..81dd5375eb 100644 --- a/src/bool/kit/kitTruth.c +++ b/src/bool/kit/kitTruth.c @@ -2036,7 +2036,7 @@ void Kit_TruthPrintProfile_int( unsigned * pTruth, int nVars ) int Unique2[20][20]; int Common2[20][20]; int nWords = Kit_TruthWordNum( nVars ); - int * pBytes = ABC_ALLOC( int, nWords * 4 ); + int * pBytes = ABC_ALLOC( int, (size_t)nWords * 4 ); unsigned * pIn = ABC_ALLOC( unsigned, nWords ); unsigned * pOut = ABC_ALLOC( unsigned, nWords ); unsigned * pCof00 = ABC_ALLOC( unsigned, nWords ); diff --git a/src/map/amap/amapMerge.c b/src/map/amap/amapMerge.c index 9b2977fa5d..6290ed8971 100644 --- a/src/map/amap/amapMerge.c +++ b/src/map/amap/amapMerge.c @@ -47,7 +47,7 @@ Amap_Cut_t * Amap_ManSetupPis( Amap_Man_t * p ) Amap_Obj_t * pObj; Amap_Cut_t * pCut; int i, nBytes = sizeof(Amap_Cut_t) + sizeof(int); - char * pBuffer = ABC_ALLOC( char, Amap_ManPiNum(p) * nBytes ); + char * pBuffer = ABC_ALLOC( char, (size_t)(Amap_ManPiNum(p)) * nBytes ); Amap_ManForEachPi( p, pObj, i ) { pCut = (Amap_Cut_t *)( pBuffer + i*nBytes ); diff --git a/src/misc/extra/extraUtilBitMatrix.c b/src/misc/extra/extraUtilBitMatrix.c index c3651fe427..a7f567f181 100644 --- a/src/misc/extra/extraUtilBitMatrix.c +++ b/src/misc/extra/extraUtilBitMatrix.c @@ -89,8 +89,8 @@ Extra_BitMat_t * Extra_BitMatrixStart( int nSize ) p->uMask = (sizeof(unsigned) == 4) ? 31: 63; p->nWords = nSize / (8 * sizeof(unsigned)) + ((nSize % (8 * sizeof(unsigned))) > 0); p->ppData = ABC_ALLOC( unsigned *, nSize ); - p->ppData[0] = ABC_ALLOC( unsigned, nSize * p->nWords ); - memset( p->ppData[0], 0, sizeof(unsigned) * nSize * p->nWords ); + p->ppData[0] = ABC_ALLOC( unsigned, (size_t)(nSize) * p->nWords ); + memset( p->ppData[0], 0, sizeof(unsigned) * (size_t)(nSize) * p->nWords ); for ( i = 1; i < nSize; i++ ) p->ppData[i] = p->ppData[i-1] + p->nWords; return p; diff --git a/src/misc/extra/extraUtilMemory.c b/src/misc/extra/extraUtilMemory.c index 673887fa3b..b201c7f8cd 100644 --- a/src/misc/extra/extraUtilMemory.c +++ b/src/misc/extra/extraUtilMemory.c @@ -35,49 +35,49 @@ struct Extra_MmFixed_t_ { // information about individual entries int nEntrySize; // the size of one entry - int nEntriesAlloc; // the total number of entries allocated - int nEntriesUsed; // the number of entries in use - int nEntriesMax; // the max number of entries in use + size_t nEntriesAlloc; // the total number of entries allocated + size_t nEntriesUsed; // the number of entries in use + size_t nEntriesMax; // the max number of entries in use char * pEntriesFree; // the linked list of free entries // this is where the memory is stored - int nChunkSize; // the size of one chunk - int nChunksAlloc; // the maximum number of memory chunks - int nChunks; // the current number of memory chunks + size_t nChunkSize; // the size of one chunk + size_t nChunksAlloc; // the maximum number of memory chunks + size_t nChunks; // the current number of memory chunks char ** pChunks; // the allocated memory // statistics - int nMemoryUsed; // memory used in the allocated entries - int nMemoryAlloc; // memory allocated + size_t nMemoryUsed; // memory used in the allocated entries + size_t nMemoryAlloc; // memory allocated }; struct Extra_MmFlex_t_ { // information about individual entries - int nEntriesUsed; // the number of entries allocated + size_t nEntriesUsed; // the number of entries allocated char * pCurrent; // the current pointer to free memory char * pEnd; // the first entry outside the free memory // this is where the memory is stored int nChunkSize; // the size of one chunk - int nChunksAlloc; // the maximum number of memory chunks - int nChunks; // the current number of memory chunks + size_t nChunksAlloc; // the maximum number of memory chunks + size_t nChunks; // the current number of memory chunks char ** pChunks; // the allocated memory // statistics - int nMemoryUsed; // memory used in the allocated entries - int nMemoryAlloc; // memory allocated + size_t nMemoryUsed; // memory used in the allocated entries + size_t nMemoryAlloc; // memory allocated }; struct Extra_MmStep_t_ { - int nMems; // the number of fixed memory managers employed + size_t nMems; // the number of fixed memory managers employed Extra_MmFixed_t ** pMems; // memory managers: 2^1 words, 2^2 words, etc - int nMapSize; // the size of the memory array + size_t 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 + size_t nLargeChunksAlloc; // the maximum number of large memory chunks + size_t nLargeChunks; // the current number of large memory chunks void ** pLargeChunks; // the allocated large memory chunks }; diff --git a/src/misc/extra/extraUtilMisc.c b/src/misc/extra/extraUtilMisc.c index e081e9c6e7..4f029e1f7a 100644 --- a/src/misc/extra/extraUtilMisc.c +++ b/src/misc/extra/extraUtilMisc.c @@ -884,7 +884,7 @@ void ** Extra_ArrayAlloc( int nCols, int nRows, int Size ) char * pBuffer; int i; assert( nCols > 0 && nRows > 0 && Size > 0 ); - pBuffer = ABC_ALLOC( char, nCols * (sizeof(void *) + nRows * Size) ); + pBuffer = ABC_ALLOC( char, nCols * (sizeof(void *) + (size_t)(nRows) * Size) ); pRes = (void **)pBuffer; pRes[0] = pBuffer + nCols * sizeof(void *); for ( i = 1; i < nCols; i++ ) diff --git a/src/misc/mem/mem.c b/src/misc/mem/mem.c index 347d0130d1..82030dde34 100644 --- a/src/misc/mem/mem.c +++ b/src/misc/mem/mem.c @@ -36,20 +36,20 @@ struct Mem_Fixed_t_ { // information about individual entries int nEntrySize; // the size of one entry - int nEntriesAlloc; // the total number of entries allocated - int nEntriesUsed; // the number of entries in use - int nEntriesMax; // the max number of entries in use + size_t nEntriesAlloc; // the total number of entries allocated + size_t nEntriesUsed; // the number of entries in use + size_t nEntriesMax; // the max number of entries in use char * pEntriesFree; // the linked list of free entries // this is where the memory is stored int nChunkSize; // the size of one chunk - int nChunksAlloc; // the maximum number of memory chunks - int nChunks; // the current number of memory chunks + size_t nChunksAlloc; // the maximum number of memory chunks + size_t nChunks; // the current number of memory chunks char ** pChunks; // the allocated memory // statistics - int nMemoryUsed; // memory used in the allocated entries - int nMemoryAlloc; // memory allocated + size_t nMemoryUsed; // memory used in the allocated entries + size_t nMemoryAlloc; // memory allocated }; struct Mem_Flex_t_ @@ -60,24 +60,24 @@ struct Mem_Flex_t_ char * pEnd; // the first entry outside the free memory // this is where the memory is stored - int nChunkSize; // the size of one chunk + size_t nChunkSize; // the size of one chunk int nChunksAlloc; // the maximum number of memory chunks - int nChunks; // the current number of memory chunks + size_t nChunks; // the current number of memory chunks char ** pChunks; // the allocated memory // statistics - int nMemoryUsed; // memory used in the allocated entries - int nMemoryAlloc; // memory allocated + size_t nMemoryUsed; // memory used in the allocated entries + size_t nMemoryAlloc; // memory allocated }; struct Mem_Step_t_ { - int nMems; // the number of fixed memory managers employed + size_t nMems; // the number of fixed memory managers employed Mem_Fixed_t ** pMems; // memory managers: 2^1 words, 2^2 words, etc - int nMapSize; // the size of the memory array + size_t nMapSize; // the size of the memory array Mem_Fixed_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 + size_t nLargeChunksAlloc; // the maximum number of large memory chunks + size_t nLargeChunks; // the current number of large memory chunks void ** pLargeChunks; // the allocated large memory chunks }; diff --git a/src/misc/mvc/mvc.h b/src/misc/mvc/mvc.h index c321259cfe..a455288bad 100644 --- a/src/misc/mvc/mvc.h +++ b/src/misc/mvc/mvc.h @@ -564,7 +564,7 @@ struct MvcManagerStruct // macros which work with memory // MEM_ALLOC: allocate the given number (Size) of items of type (Type) // MEM_FREE: deallocate the pointer (Pointer) to the given number (Size) of items of type (Type) -#define MEM_ALLOC( Manager, Type, Size ) ((Type *)ABC_ALLOC( char, (Size) * sizeof(Type) )) +#define MEM_ALLOC( Manager, Type, Size ) ((Type *)ABC_ALLOC( char, (size_t)(Size) * sizeof(Type) )) #define MEM_FREE( Manager, Type, Size, Pointer ) if ( Pointer ) { ABC_FREE(Pointer); Pointer = NULL; } //////////////////////////////////////////////////////////////////////// diff --git a/src/misc/tim/timMan.c b/src/misc/tim/timMan.c index 151bf91d1a..504ac64be7 100644 --- a/src/misc/tim/timMan.c +++ b/src/misc/tim/timMan.c @@ -123,7 +123,7 @@ Tim_Man_t * Tim_ManDup( Tim_Man_t * p, int fUnitDelay ) assert( i == (int)pDelayTable[0] ); nInputs = (int)pDelayTable[1]; nOutputs = (int)pDelayTable[2]; - pDelayTableNew = ABC_ALLOC( float, 3 + nInputs * nOutputs ); + pDelayTableNew = ABC_ALLOC( float, 3 + (size_t)(nInputs) * (size_t)(nOutputs) ); pDelayTableNew[0] = (int)pDelayTable[0]; pDelayTableNew[1] = (int)pDelayTable[1]; pDelayTableNew[2] = (int)pDelayTable[2]; @@ -208,7 +208,7 @@ Tim_Man_t * Tim_ManTrim( Tim_Man_t * p, Vec_Int_t * vBoxPres ) assert( i == (int)pDelayTable[0] ); nInputs = (int)pDelayTable[1]; nOutputs = (int)pDelayTable[2]; - pDelayTableNew = ABC_ALLOC( float, 3 + nInputs * nOutputs ); + pDelayTableNew = ABC_ALLOC( float, 3 + (size_t)(nInputs) * (size_t)(nOutputs) ); pDelayTableNew[0] = (int)pDelayTable[0]; pDelayTableNew[1] = (int)pDelayTable[1]; pDelayTableNew[2] = (int)pDelayTable[2]; @@ -301,7 +301,7 @@ Tim_Man_t * Tim_ManReduce( Tim_Man_t * p, Vec_Int_t * vBoxesLeft, int nTermsDiff //assert( i == (int)pDelayTable[0] ); nInputs = (int)pDelayTable[1]; nOutputs = (int)pDelayTable[2]; - pDelayTableNew = ABC_ALLOC( float, 3 + nInputs * nOutputs ); + pDelayTableNew = ABC_ALLOC( float, 3 + (size_t)(nInputs) * (size_t)(nOutputs) ); pDelayTableNew[0] = i;//(int)pDelayTable[0]; pDelayTableNew[1] = (int)pDelayTable[1]; pDelayTableNew[2] = (int)pDelayTable[2]; @@ -419,7 +419,7 @@ void Tim_ManCreate( Tim_Man_t * p, void * pLib, Vec_Flt_t * vInArrs, Vec_Flt_t * if ( pBox->iDelayTable == -1 || pLibBox == NULL ) { // create table with constants - pTable = ABC_ALLOC( float, 3 + pBox->nInputs * pBox->nOutputs ); + pTable = ABC_ALLOC( float, 3 + (size_t)(pBox->nInputs) * (size_t)(pBox->nOutputs) ); pTable[0] = pBox->iDelayTable; pTable[1] = pBox->nInputs; pTable[2] = pBox->nOutputs; @@ -439,7 +439,7 @@ void Tim_ManCreate( Tim_Man_t * p, void * pLib, Vec_Flt_t * vInArrs, Vec_Flt_t * if ( Vec_PtrEntry( p->vDelayTables, pBox->iDelayTable ) != NULL ) continue; // create table of boxes - pTable = ABC_ALLOC( float, 3 + pBox->nInputs * pBox->nOutputs ); + pTable = ABC_ALLOC( float, 3 + (size_t)(pBox->nInputs) * (size_t)(pBox->nOutputs) ); pTable[0] = pBox->iDelayTable; pTable[1] = pBox->nInputs; pTable[2] = pBox->nOutputs; diff --git a/src/opt/csw/cswMan.c b/src/opt/csw/cswMan.c index aa5d2dea10..855a94a05c 100644 --- a/src/opt/csw/cswMan.c +++ b/src/opt/csw/cswMan.c @@ -78,7 +78,7 @@ Csw_Man_t * Csw_ManStart( Aig_Man_t * pMan, int nCutsMax, int nLeafMax, int fVer Aig_ManForEachCi( p->pManAig, pObj, i ) Csw_ObjSetEquiv( p, pObj, Aig_ManCi(p->pManRes, i) ); // room for temporary truth tables - p->puTemp[0] = ABC_ALLOC( unsigned, 4 * p->nTruthWords ); + p->puTemp[0] = ABC_ALLOC( unsigned, 4 * (size_t)(p->nTruthWords) ); p->puTemp[1] = p->puTemp[0] + p->nTruthWords; p->puTemp[2] = p->puTemp[1] + p->nTruthWords; p->puTemp[3] = p->puTemp[2] + p->nTruthWords; diff --git a/src/opt/cut/cutMan.c b/src/opt/cut/cutMan.c index 2a82d8bb6a..056e8fa94e 100644 --- a/src/opt/cut/cutMan.c +++ b/src/opt/cut/cutMan.c @@ -85,7 +85,7 @@ Cut_Man_t * Cut_ManStart( Cut_Params_t * pParams ) p->nTruthWords = Cut_TruthWords( pParams->nVarsMax ); p->EntrySize += p->nTruthWords * sizeof(unsigned); } - p->puTemp[0] = ABC_ALLOC( unsigned, 4 * p->nTruthWords ); + p->puTemp[0] = ABC_ALLOC( unsigned, 4 * (size_t)(p->nTruthWords) ); p->puTemp[1] = p->puTemp[0] + p->nTruthWords; p->puTemp[2] = p->puTemp[1] + p->nTruthWords; p->puTemp[3] = p->puTemp[2] + p->nTruthWords; diff --git a/src/opt/dsc/dsc.c b/src/opt/dsc/dsc.c index 7ddeeed99d..ac0d4a1f72 100644 --- a/src/opt/dsc/dsc.c +++ b/src/opt/dsc/dsc.c @@ -288,7 +288,7 @@ void dsc_xor_group(Dsc_node_t * pOut, Dsc_node_t * ni, Dsc_node_t * nj, int nVar * the boolean difference for each input variable */ extern word * Dsc_alloc_pool(int nVars) { - return ABC_ALLOC(word, 3 * Abc_TtWordNum(nVars) * nVars); + return ABC_ALLOC(word, 3 * (size_t)(Abc_TtWordNum(nVars)) * (size_t)(nVars)); } /** @@ -325,7 +325,7 @@ extern int Dsc_Decompose(word * pTruth, const int nVarsInit, char * const pRes, pRes[1] = '\0'; if (NEED_POOL_ALLOC) - pool = ABC_ALLOC(word, 3 * TRUTH_WORDS * nVarsInit); + pool = ABC_ALLOC(word, 3 * (size_t)(TRUTH_WORDS) * (size_t)(nVarsInit)); // block for the node data allocation { diff --git a/src/opt/fsim/fsimFront.c b/src/opt/fsim/fsimFront.c index 6169543c3d..67d32f7e55 100644 --- a/src/opt/fsim/fsimFront.c +++ b/src/opt/fsim/fsimFront.c @@ -270,7 +270,7 @@ void Fsim_ManFront( Fsim_Man_t * p, int fCompressAig ) } else { - p->pDataAig2 = ABC_ALLOC( int, 3 * p->nObjs ); + p->pDataAig2 = ABC_ALLOC( int, 3 * size_t(p->nObjs) ); p->pDataCur2 = p->pDataAig2 + 6; } // iterate through the objects diff --git a/src/opt/fsim/fsimSim.c b/src/opt/fsim/fsimSim.c index 1458363828..fc146ab035 100644 --- a/src/opt/fsim/fsimSim.c +++ b/src/opt/fsim/fsimSim.c @@ -514,9 +514,9 @@ int Fsim_ManSimulate( Aig_Man_t * pAig, Fsim_ParSim_t * pPars ) // perform simulation Aig_ManRandom( 1 ); assert( p->pDataSim == NULL ); - p->pDataSim = ABC_ALLOC( unsigned, p->nWords * p->nFront ); - p->pDataSimCis = ABC_ALLOC( unsigned, p->nWords * p->nCis ); - p->pDataSimCos = ABC_ALLOC( unsigned, p->nWords * p->nCos ); + p->pDataSim = ABC_ALLOC( unsigned, size_t(p->nWords) * p->nFront ); + p->pDataSimCis = ABC_ALLOC( unsigned, size_t(p->nWords) * p->nCis ); + p->pDataSimCos = ABC_ALLOC( unsigned, size_t(p->nWords) * p->nCos ); Fsim_ManSimInfoInit( p ); for ( i = 0; i < pPars->nIters; i++ ) { diff --git a/src/opt/fxu/fxuCreate.c b/src/opt/fxu/fxuCreate.c index 8d5b2f5446..09b5d44575 100644 --- a/src/opt/fxu/fxuCreate.c +++ b/src/opt/fxu/fxuCreate.c @@ -100,8 +100,8 @@ Fxu_Matrix * Fxu_CreateMatrix( Fxu_Data_t * pData ) // start the matrix p = Fxu_MatrixAllocate(); // create the column labels - p->ppVars = ABC_ALLOC( Fxu_Var *, 2 * (pData->nNodesOld + pData->nNodesExt) ); - for ( i = 0; i < 2 * pData->nNodesOld; i++ ) + p->ppVars = ABC_ALLOC( Fxu_Var *, 2 * (size_t)(pData->nNodesOld + pData->nNodesExt) ); + for ( i = 0; i < 2 * (size_t)(pData->nNodesOld); i++ ) p->ppVars[i] = Fxu_MatrixAddVar( p ); // allocate storage for all cube pairs at once diff --git a/src/opt/fxu/fxuInt.h b/src/opt/fxu/fxuInt.h index b68f9ea62f..ec4be616a6 100644 --- a/src/opt/fxu/fxuInt.h +++ b/src/opt/fxu/fxuInt.h @@ -423,7 +423,7 @@ extern void Fxu_MatrixRingVarsUnmark( Fxu_Matrix * p ); // MEM_ALLOC: allocate the given number (Size) of items of type (Type) // MEM_FREE: deallocate the pointer (Pointer) to the given number (Size) of items of type (Type) #ifdef USE_SYSTEM_MEMORY_MANAGEMENT -#define MEM_ALLOC_FXU( Manager, Type, Size ) ((Type *)ABC_ALLOC( char, (Size) * sizeof(Type) )) +#define MEM_ALLOC_FXU( Manager, Type, Size ) ((Type *)ABC_ALLOC( char, size_t(Size) * sizeof(Type) )) #define MEM_FREE_FXU( Manager, Type, Size, Pointer ) if ( Pointer ) { ABC_FREE(Pointer); Pointer = NULL; } #else #define MEM_ALLOC_FXU( Manager, Type, Size )\ diff --git a/src/opt/fxu/fxuPair.c b/src/opt/fxu/fxuPair.c index 32822592f6..b676046aa9 100644 --- a/src/opt/fxu/fxuPair.c +++ b/src/opt/fxu/fxuPair.c @@ -456,8 +456,8 @@ void Fxu_PairAllocStorage( Fxu_Var * pVar, int nCubes ) pVar->nCubes = nCubes; // allocate memory for all the pairs pVar->ppPairs = ABC_ALLOC( Fxu_Pair **, nCubes ); - pVar->ppPairs[0] = ABC_ALLOC( Fxu_Pair *, nCubes * nCubes ); - memset( pVar->ppPairs[0], 0, sizeof(Fxu_Pair *) * nCubes * nCubes ); + pVar->ppPairs[0] = ABC_ALLOC( Fxu_Pair *, (size_t)(nCubes) * (size_t)(nCubes) ); + memset( pVar->ppPairs[0], 0, sizeof(Fxu_Pair *) * (size_t)(nCubes) * (size_t)(nCubes) ); for ( k = 1; k < nCubes; k++ ) pVar->ppPairs[k] = pVar->ppPairs[k-1] + nCubes; } diff --git a/src/opt/nwk/nwkSpeedup.c b/src/opt/nwk/nwkSpeedup.c index 14840ecb6d..05ad5c0b0a 100644 --- a/src/opt/nwk/nwkSpeedup.c +++ b/src/opt/nwk/nwkSpeedup.c @@ -233,7 +233,7 @@ Aig_Man_t * Nwk_ManSpeedup( Nwk_Man_t * pNtk, int fUseLutLib, int Percentage, in } // mark the timing critical nodes and edges puTCEdges = ABC_ALLOC( unsigned, Nwk_ManObjNumMax(pNtk) ); - memset( puTCEdges, 0, sizeof(unsigned) * Nwk_ManObjNumMax(pNtk) ); + memset( puTCEdges, 0, sizeof(unsigned) * (size_t)(Nwk_ManObjNumMax(pNtk)) ); Nwk_ManForEachNode( pNtk, pNode, i ) { if ( Nwk_ObjSlack(pNode) >= tDelta ) diff --git a/src/opt/sim/simUtils.c b/src/opt/sim/simUtils.c index dc05df0f58..ebc0c9ee51 100644 --- a/src/opt/sim/simUtils.c +++ b/src/opt/sim/simUtils.c @@ -60,9 +60,9 @@ Vec_Ptr_t * Sim_UtilInfoAlloc( int nSize, int nWords, int fClean ) int i; assert( nSize > 0 && nWords > 0 ); vInfo = Vec_PtrAlloc( nSize ); - vInfo->pArray[0] = ABC_ALLOC( unsigned, nSize * nWords ); + vInfo->pArray[0] = ABC_ALLOC( unsigned, nSize * (size_t)(nWords) ); if ( fClean ) - memset( vInfo->pArray[0], 0, sizeof(unsigned) * nSize * nWords ); + memset( vInfo->pArray[0], 0, sizeof(unsigned) * nSize * (size_t)(nWords) ); for ( i = 1; i < nSize; i++ ) vInfo->pArray[i] = ((unsigned *)vInfo->pArray[i-1]) + nWords; vInfo->nSize = nSize; diff --git a/src/proof/cec/cecSim.c b/src/proof/cec/cecSim.c index 48a789f39e..22b1666568 100644 --- a/src/proof/cec/cecSim.c +++ b/src/proof/cec/cecSim.c @@ -78,7 +78,7 @@ Cec_ManS_t * Cec_ManSStart( Gia_Man_t * pAig, int nWords ) p->vInputs = Vec_IntAlloc( 100 ); p->vLevels = Vec_WecStart( Gia_ManLevelNum(pAig) + 1 ); p->vSims = Vec_WrdStart( Gia_ManObjNum(pAig) * nWords * 2 ); - p->pTemp[0] = ABC_ALLOC( word, 4*nWords ); + p->pTemp[0] = ABC_ALLOC( word, 4*(size_t)(nWords) ); for ( i = 1; i < 4; i++ ) p->pTemp[i] = p->pTemp[i-1] + nWords; for ( i = 0; i < SIM_RANDS; i++ ) diff --git a/src/proof/fraig/fraigMan.c b/src/proof/fraig/fraigMan.c index 90c009ef42..d308bb932f 100644 --- a/src/proof/fraig/fraigMan.c +++ b/src/proof/fraig/fraigMan.c @@ -393,10 +393,10 @@ Fraig_NodeVec_t * Fraig_UtilInfoAlloc( int nSize, int nWords, int fClean ) int i; assert( nSize > 0 && nWords > 0 ); vInfo = Fraig_NodeVecAlloc( nSize ); - pUnsigned = ABC_ALLOC( unsigned, nSize * nWords ); + pUnsigned = ABC_ALLOC( unsigned, (size_t)(nSize) * (size_t)(nWords) ); vInfo->pArray[0] = (Fraig_Node_t *)pUnsigned; if ( fClean ) - memset( pUnsigned, 0, sizeof(unsigned) * nSize * nWords ); + memset( pUnsigned, 0, sizeof(unsigned) * (size_t)(nSize) * (size_t)(nWords) ); for ( i = 1; i < nSize; i++ ) vInfo->pArray[i] = (Fraig_Node_t *)(((unsigned *)vInfo->pArray[i-1]) + nWords); vInfo->nSize = nSize; diff --git a/src/proof/fraig/fraigMem.c b/src/proof/fraig/fraigMem.c index ef52765e26..60930828d7 100644 --- a/src/proof/fraig/fraigMem.c +++ b/src/proof/fraig/fraigMem.c @@ -29,20 +29,20 @@ struct Fraig_MemFixed_t_ { // information about individual entries int nEntrySize; // the size of one entry - int nEntriesAlloc; // the total number of entries allocated - int nEntriesUsed; // the number of entries in use - int nEntriesMax; // the max number of entries in use + size_t nEntriesAlloc; // the total number of entries allocated + size_t nEntriesUsed; // the number of entries in use + size_t nEntriesMax; // the max number of entries in use char * pEntriesFree; // the linked list of free entries // this is where the memory is stored int nChunkSize; // the size of one chunk - int nChunksAlloc; // the maximum number of memory chunks - int nChunks; // the current number of memory chunks + size_t nChunksAlloc; // the maximum number of memory chunks + size_t nChunks; // the current number of memory chunks char ** pChunks; // the allocated memory // statistics - int nMemoryUsed; // memory used in the allocated entries - int nMemoryAlloc; // memory allocated + size_t nMemoryUsed; // memory used in the allocated entries + size_t nMemoryAlloc; // memory allocated }; //////////////////////////////////////////////////////////////////////// diff --git a/src/sat/bsat/satMem.c b/src/sat/bsat/satMem.c index 187d8d0a13..d64d795ac1 100644 --- a/src/sat/bsat/satMem.c +++ b/src/sat/bsat/satMem.c @@ -36,49 +36,49 @@ struct Sat_MmFixed_t_ { // information about individual entries int nEntrySize; // the size of one entry - int nEntriesAlloc; // the total number of entries allocated - int nEntriesUsed; // the number of entries in use - int nEntriesMax; // the max number of entries in use + size_t nEntriesAlloc; // the total number of entries allocated + size_t nEntriesUsed; // the number of entries in use + size_t nEntriesMax; // the max number of entries in use char * pEntriesFree; // the linked list of free entries // this is where the memory is stored int nChunkSize; // the size of one chunk - int nChunksAlloc; // the maximum number of memory chunks - int nChunks; // the current number of memory chunks + size_t nChunksAlloc; // the maximum number of memory chunks + size_t nChunks; // the current number of memory chunks char ** pChunks; // the allocated memory // statistics - int nMemoryUsed; // memory used in the allocated entries - int nMemoryAlloc; // memory allocated + size_t nMemoryUsed; // memory used in the allocated entries + size_t nMemoryAlloc; // memory allocated }; struct Sat_MmFlex_t_ { // information about individual entries - int nEntriesUsed; // the number of entries allocated + size_t nEntriesUsed; // the number of entries allocated char * pCurrent; // the current pointer to free memory char * pEnd; // the first entry outside the free memory // this is where the memory is stored int nChunkSize; // the size of one chunk - int nChunksAlloc; // the maximum number of memory chunks - int nChunks; // the current number of memory chunks + size_t nChunksAlloc; // the maximum number of memory chunks + size_t nChunks; // the current number of memory chunks char ** pChunks; // the allocated memory // statistics - int nMemoryUsed; // memory used in the allocated entries - int nMemoryAlloc; // memory allocated + size_t nMemoryUsed; // memory used in the allocated entries + size_t nMemoryAlloc; // memory allocated }; struct Sat_MmStep_t_ { - int nMems; // the number of fixed memory managers employed + size_t nMems; // the number of fixed memory managers employed Sat_MmFixed_t ** pMems; // memory managers: 2^1 words, 2^2 words, etc - int nMapSize; // the size of the memory array + size_t nMapSize; // the size of the memory array Sat_MmFixed_t ** pMap; // maps the number of bytes into its memory manager // additional memory chunks - int nChunksAlloc; // the maximum number of memory chunks - int nChunks; // the current number of memory chunks + size_t nChunksAlloc; // the maximum number of memory chunks + size_t nChunks; // the current number of memory chunks char ** pChunks; // the allocated memory }; @@ -180,8 +180,8 @@ char * Sat_MmFixedEntryFetch( Sat_MmFixed_t * p ) p->nChunksAlloc *= 2; p->pChunks = ABC_REALLOC( char *, p->pChunks, p->nChunksAlloc ); } - p->pEntriesFree = ABC_ALLOC( char, p->nEntrySize * p->nChunkSize ); - p->nMemoryAlloc += p->nEntrySize * p->nChunkSize; + p->pEntriesFree = ABC_ALLOC( char, (size_t)(p->nEntrySize) * (size_t)(p->nChunkSize) ); + p->nMemoryAlloc += (size_t)(p->nEntrySize) * (size_t)(p->nChunkSize); // transform these entries into a linked list pTemp = p->pEntriesFree; for ( i = 1; i < p->nChunkSize; i++ ) diff --git a/src/sat/msat/msatMem.c b/src/sat/msat/msatMem.c index 7e0dc0dd12..23d3174184 100644 --- a/src/sat/msat/msatMem.c +++ b/src/sat/msat/msatMem.c @@ -31,46 +31,46 @@ struct Msat_MmFixed_t_ { // information about individual entries int nEntrySize; // the size of one entry - int nEntriesAlloc; // the total number of entries allocated - int nEntriesUsed; // the number of entries in use - int nEntriesMax; // the max number of entries in use + size_t nEntriesAlloc; // the total number of entries allocated + size_t nEntriesUsed; // the number of entries in use + size_t nEntriesMax; // the max number of entries in use char * pEntriesFree; // the linked list of free entries // this is where the memory is stored int nChunkSize; // the size of one chunk - int nChunksAlloc; // the maximum number of memory chunks - int nChunks; // the current number of memory chunks + size_t nChunksAlloc; // the maximum number of memory chunks + size_t nChunks; // the current number of memory chunks char ** pChunks; // the allocated memory // statistics - int nMemoryUsed; // memory used in the allocated entries - int nMemoryAlloc; // memory allocated + size_t nMemoryUsed; // memory used in the allocated entries + size_t nMemoryAlloc; // memory allocated }; struct Msat_MmFlex_t_ { // information about individual entries - int nEntriesUsed; // the number of entries allocated + size_t nEntriesUsed; // the number of entries allocated char * pCurrent; // the current pointer to free memory char * pEnd; // the first entry outside the free memory // this is where the memory is stored int nChunkSize; // the size of one chunk - int nChunksAlloc; // the maximum number of memory chunks - int nChunks; // the current number of memory chunks + size_t nChunksAlloc; // the maximum number of memory chunks + size_t nChunks; // the current number of memory chunks char ** pChunks; // the allocated memory // statistics - int nMemoryUsed; // memory used in the allocated entries - int nMemoryAlloc; // memory allocated + size_t nMemoryUsed; // memory used in the allocated entries + size_t nMemoryAlloc; // memory allocated }; struct Msat_MmStep_t_ { - int nMems; // the number of fixed memory managers employed + size_t nMems; // the number of fixed memory managers employed Msat_MmFixed_t ** pMems; // memory managers: 2^1 words, 2^2 words, etc - int nMapSize; // the size of the memory array + size_t nMapSize; // the size of the memory array Msat_MmFixed_t ** pMap; // maps the number of bytes into its memory manager };