summaryrefslogtreecommitdiffstats
path: root/src/misc/extra/extraUtilMemory.c
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2006-05-08 08:01:00 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2006-05-08 08:01:00 -0700
commit7d0921330b1f4e789901b4c2450920e7c412f95f (patch)
treebbbb9b1a6d92a989cd395e17945dda22503acccf /src/misc/extra/extraUtilMemory.c
parent73b8d1dd79f4cca7821b78df0da999d6ea6872e6 (diff)
downloadabc-7d0921330b1f4e789901b4c2450920e7c412f95f.tar.gz
abc-7d0921330b1f4e789901b4c2450920e7c412f95f.tar.bz2
abc-7d0921330b1f4e789901b4c2450920e7c412f95f.zip
Version abc60508
Diffstat (limited to 'src/misc/extra/extraUtilMemory.c')
-rw-r--r--src/misc/extra/extraUtilMemory.c21
1 files changed, 21 insertions, 0 deletions
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] );