summaryrefslogtreecommitdiffstats
path: root/src/misc/extra/extraUtilMemory.c
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2008-01-30 08:01:00 -0800
committerAlan Mishchenko <alanmi@berkeley.edu>2008-01-30 08:01:00 -0800
commit4d30a1e4f1edecff86d5066ce4653a370e59e5e1 (patch)
tree366355938a4af0a92f848841ac65374f338d691b /src/misc/extra/extraUtilMemory.c
parent6537f941887b06e588d3acfc97b5fdf48875cc4e (diff)
downloadabc-4d30a1e4f1edecff86d5066ce4653a370e59e5e1.tar.gz
abc-4d30a1e4f1edecff86d5066ce4653a370e59e5e1.tar.bz2
abc-4d30a1e4f1edecff86d5066ce4653a370e59e5e1.zip
Version abc80130
Diffstat (limited to 'src/misc/extra/extraUtilMemory.c')
-rw-r--r--src/misc/extra/extraUtilMemory.c103
1 files changed, 21 insertions, 82 deletions
diff --git a/src/misc/extra/extraUtilMemory.c b/src/misc/extra/extraUtilMemory.c
index 6eccf015..af1128ac 100644
--- a/src/misc/extra/extraUtilMemory.c
+++ b/src/misc/extra/extraUtilMemory.c
@@ -73,9 +73,6 @@ 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
};
/*---------------------------------------------------------------------------*/
@@ -155,30 +152,18 @@ Extra_MmFixed_t * Extra_MmFixedStart( int nEntrySize )
SeeAlso []
***********************************************************************/
-void Extra_MmFixedPrint( Extra_MmFixed_t * p )
-{
- printf( "Fixed memory manager: Entry = %5d. Chunk = %5d. Chunks used = %5d.\n",
- p->nEntrySize, p->nChunkSize, p->nChunks );
- printf( " Entries used = %8d. Entries peak = %8d. Memory used = %8d. Memory alloc = %8d.\n",
- p->nEntriesUsed, p->nEntriesMax, p->nEntrySize * p->nEntriesUsed, p->nMemoryAlloc );
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Extra_MmFixedStop( Extra_MmFixed_t * p )
+void Extra_MmFixedStop( Extra_MmFixed_t * p, int fVerbose )
{
int i;
if ( p == NULL )
return;
+ if ( fVerbose )
+ {
+ printf( "Fixed memory manager: Entry = %5d. Chunk = %5d. Chunks used = %5d.\n",
+ p->nEntrySize, p->nChunkSize, p->nChunks );
+ printf( " Entries used = %8d. Entries peak = %8d. Memory used = %8d. Memory alloc = %8d.\n",
+ p->nEntriesUsed, p->nEntriesMax, p->nEntrySize * p->nEntriesUsed, p->nMemoryAlloc );
+ }
for ( i = 0; i < p->nChunks; i++ )
free( p->pChunks[i] );
free( p->pChunks );
@@ -272,7 +257,7 @@ void Extra_MmFixedRestart( Extra_MmFixed_t * p )
int i;
char * pTemp;
- // deallocate all chunks except the first one
+ // delocate all chunks except the first one
for ( i = 1; i < p->nChunks; i++ )
free( p->pChunks[i] );
p->nChunks = 1;
@@ -310,21 +295,6 @@ int Extra_MmFixedReadMemUsage( Extra_MmFixed_t * p )
return p->nMemoryAlloc;
}
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-int Extra_MmFixedReadMaxEntriesUsed( Extra_MmFixed_t * p )
-{
- return p->nEntriesMax;
-}
/**Function*************************************************************
@@ -341,7 +311,7 @@ int Extra_MmFixedReadMaxEntriesUsed( Extra_MmFixed_t * p )
Extra_MmFlex_t * Extra_MmFlexStart()
{
Extra_MmFlex_t * p;
-//printf( "allocing flex\n" );
+
p = ALLOC( Extra_MmFlex_t, 1 );
memset( p, 0, sizeof(Extra_MmFlex_t) );
@@ -349,7 +319,7 @@ Extra_MmFlex_t * Extra_MmFlexStart()
p->pCurrent = NULL;
p->pEnd = NULL;
- p->nChunkSize = (1 << 10);
+ p->nChunkSize = (1 << 12);
p->nChunksAlloc = 64;
p->nChunks = 0;
p->pChunks = ALLOC( char *, p->nChunksAlloc );
@@ -370,31 +340,18 @@ Extra_MmFlex_t * Extra_MmFlexStart()
SeeAlso []
***********************************************************************/
-void Extra_MmFlexPrint( Extra_MmFlex_t * p )
-{
- printf( "Flexible memory manager: Chunk size = %d. Chunks used = %d.\n",
- p->nChunkSize, p->nChunks );
- printf( " Entries used = %d. Memory used = %d. Memory alloc = %d.\n",
- p->nEntriesUsed, p->nMemoryUsed, p->nMemoryAlloc );
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Extra_MmFlexStop( Extra_MmFlex_t * p )
+void Extra_MmFlexStop( Extra_MmFlex_t * p, int fVerbose )
{
int i;
if ( p == NULL )
return;
-//printf( "deleting flex\n" );
+ if ( fVerbose )
+ {
+ printf( "Flexible memory manager: Chunk size = %d. Chunks used = %d.\n",
+ p->nChunkSize, p->nChunks );
+ printf( " Entries used = %d. Memory used = %d. Memory alloc = %d.\n",
+ p->nEntriesUsed, p->nMemoryUsed, p->nMemoryAlloc );
+ }
for ( i = 0; i < p->nChunks; i++ )
free( p->pChunks[i] );
free( p->pChunks );
@@ -491,7 +448,6 @@ 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 );
@@ -522,17 +478,11 @@ Extra_MmStep_t * Extra_MmStepStart( int nSteps )
SeeAlso []
***********************************************************************/
-void Extra_MmStepStop( Extra_MmStep_t * p )
+void Extra_MmStepStop( Extra_MmStep_t * p, int fVerbose )
{
int i;
for ( i = 0; i < p->nMems; i++ )
- Extra_MmFixedStop( p->pMems[i] );
-// if ( p->pLargeChunks )
-// {
-// for ( i = 0; i < p->nLargeChunks; i++ )
-// free( p->pLargeChunks[i] );
-// free( p->pLargeChunks );
-// }
+ Extra_MmFixedStop( p->pMems[i], fVerbose );
free( p->pMems );
free( p->pMap );
free( p );
@@ -556,17 +506,6 @@ 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] );