crblib/mempool.c
/*
 * HunkLength is forced to be a multiple of 4
 */
HunkLength is forced to be a multiple of 4
HunkLength is forced to be a multiple of 4
MemPool * AllocPool (long HunkLength,long NumHunks,long AutoExtendNumItems)
{
MemPool * Ret;
if ( (Ret = malloc(sizeof(MemPool))) == NULL )
  return(NULL);
Ret->HunkLength = PaddedSize(HunkLength);
Ret->CurMemBlock = NULL;
Ret->MemBlock = NULL;
Ret->NumFreedHunks = 0;
Ret->MaxNumFreedHunks = 16;
Ret->AutoExtendNumItems = AutoExtendNumItems;
Ret->NumItemsActive = 0;
if ( (Ret->FreedHunks = malloc(Ret->MaxNumFreedHunks*sizeofpointer)) == NULL )
  {
  free(Ret);
  return(NULL);
  }
if ( ! ExtendPool(Ret,NumHunks) )
  {
  free(Ret->FreedHunks);
  free(Ret);
  return(NULL);
  }
return(Ret);
}
MemPool * AllocPool ( long HunkLength , long NumHunks , long AutoExtendNumItems ) { MemPool * Ret ; if ( ( Ret = malloc ( sizeof ( MemPool ) ) ) == NULL ) return ( NULL ) ; Ret -> HunkLength = PaddedSize ( HunkLength ) ; Ret -> CurMemBlock = NULL ; Ret -> MemBlock = NULL ; Ret -> NumFreedHunks = 0 ; Ret -> MaxNumFreedHunks = 16 ; Ret -> AutoExtendNumItems = AutoExtendNumItems ; Ret -> NumItemsActive = 0 ; if ( ( Ret -> FreedHunks = malloc ( Ret -> MaxNumFreedHunks * sizeofpointer ) ) == NULL ) { free ( Ret ) ; return ( NULL ) ; } if ( ! ExtendPool ( Ret , NumHunks ) ) { free ( Ret -> FreedHunks ) ; free ( Ret ) ; return ( NULL ) ; } return ( Ret ) ; }
HunkLength is forced to be a multiple of 4
HunkLength is forced to be a multiple of 4