Replaced literal constants with class static data members. (for clarity)
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@387 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
44cead8a69
commit
cb2a534d00
1 changed files with 14 additions and 2 deletions
|
@ -212,6 +212,12 @@ namespace Loki
|
||||||
/// Iterator through const container of Chunks.
|
/// Iterator through const container of Chunks.
|
||||||
typedef Chunks::const_iterator ChunkCIter;
|
typedef Chunks::const_iterator ChunkCIter;
|
||||||
|
|
||||||
|
/// Fewest # of objects managed by a Chunk.
|
||||||
|
static unsigned char MinObjectsPerChunk_;
|
||||||
|
|
||||||
|
/// Most # of objects managed by a Chunk - never exceeds UCHAR_MAX.
|
||||||
|
static unsigned char MaxObjectsPerChunk_;
|
||||||
|
|
||||||
/// Number of bytes in a single block within a Chunk.
|
/// Number of bytes in a single block within a Chunk.
|
||||||
std::size_t blockSize_;
|
std::size_t blockSize_;
|
||||||
/// Number of blocks managed by each Chunk.
|
/// Number of blocks managed by each Chunk.
|
||||||
|
@ -282,6 +288,9 @@ namespace Loki
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
unsigned char FixedAllocator::MinObjectsPerChunk_ = 8;
|
||||||
|
unsigned char FixedAllocator::MaxObjectsPerChunk_ = UCHAR_MAX;
|
||||||
|
|
||||||
// Chunk::Init ----------------------------------------------------------------
|
// Chunk::Init ----------------------------------------------------------------
|
||||||
|
|
||||||
bool Chunk::Init( std::size_t blockSize, unsigned char blocks )
|
bool Chunk::Init( std::size_t blockSize, unsigned char blocks )
|
||||||
|
@ -553,8 +562,8 @@ void FixedAllocator::Initialize( std::size_t blockSize, std::size_t pageSize )
|
||||||
blockSize_ = blockSize;
|
blockSize_ = blockSize;
|
||||||
|
|
||||||
std::size_t numBlocks = pageSize / blockSize;
|
std::size_t numBlocks = pageSize / blockSize;
|
||||||
if (numBlocks > UCHAR_MAX) numBlocks = UCHAR_MAX;
|
if ( numBlocks > MaxObjectsPerChunk_ ) numBlocks = MaxObjectsPerChunk_;
|
||||||
else if ( numBlocks < 8 ) numBlocks = 8;
|
else if ( numBlocks < MinObjectsPerChunk_ ) numBlocks = MinObjectsPerChunk_;
|
||||||
|
|
||||||
numBlocks_ = static_cast<unsigned char>(numBlocks);
|
numBlocks_ = static_cast<unsigned char>(numBlocks);
|
||||||
assert(numBlocks_ == numBlocks);
|
assert(numBlocks_ == numBlocks);
|
||||||
|
@ -1182,6 +1191,9 @@ bool SmallObjAllocator::IsCorrupt( void ) const
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// $Log$
|
// $Log$
|
||||||
|
// Revision 1.20 2005/12/28 22:34:53 rich_sposato
|
||||||
|
// Replaced literal constants with class static data members. (for clarity)
|
||||||
|
//
|
||||||
// Revision 1.19 2005/12/19 08:05:46 syntheticpp
|
// Revision 1.19 2005/12/19 08:05:46 syntheticpp
|
||||||
// remove warnings when NDEBUG is defined
|
// remove warnings when NDEBUG is defined
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue