19#if !defined(REUSABLEARENABLOCK_INCLUDE_GUARD_1357924680)
20#define REUSABLEARENABLOCK_INCLUDE_GUARD_1357924680
35template <
class ObjectType,
36#if defined(XALAN_NO_DEFAULT_TEMPLATE_ARGUMENTS)
39 class SizeType =
unsigned short>
69 (
next <= rightBorder ) ) ? true : false ;
81 MemoryManager& theManager,
88 XALAN_STATIC_ASSERT(
sizeof(ObjectType) >=
sizeof(NextBlock));
116 MemoryManager& theManager,
139 assert ( this->m_firstFreeBlock == (this->
m_blockSize + 1) );
147 ObjectType* theResult = 0;
149 assert ( this->m_firstFreeBlock <= this->
m_blockSize );
150 assert ( this->m_nextFreeBlock <= this->
m_blockSize );
153 if(this->m_firstFreeBlock != this->m_nextFreeBlock)
164 NextBlock*
const theBlock =
165 reinterpret_cast<NextBlock*
>(theResult);
167 this->m_nextFreeBlock = theBlock->next;
169 assert(theBlock->isValidFor(this->m_blockSize));
170 assert(this->m_nextFreeBlock <= this->
m_blockSize);
187 assert ( this->m_objectCount <= this->
m_blockSize );
189 this->m_firstFreeBlock = this->m_nextFreeBlock;
202 assert(theObject != 0);
205 if ( this->m_firstFreeBlock != this->m_nextFreeBlock )
208 void*
const p = this->
m_objectBlock + this->m_firstFreeBlock;
210 new (p) NextBlock(this->m_nextFreeBlock);
212 this->m_nextFreeBlock = this->m_firstFreeBlock;
220 new (theObject) NextBlock(this->m_firstFreeBlock);
223 this->m_nextFreeBlock =
226 assert (this->m_firstFreeBlock <= this->
m_blockSize);
243 assert ( theObject != 0 );
264 return !isOnFreeList(theObject);
273 reinterpret_cast<const NextBlock*
>(block)->isValidFor(this->
m_blockSize));
297 isOnFreeList(
const ObjectType* theObject)
const
299 if ( this->m_objectCount == 0 )
305 ObjectType* pRunPtr = this->m_objectBlock + this->m_firstFreeBlock;
307 for (size_type i = 0;
308 i < this->m_blockSize - this->m_objectCount;
311 assert(this->ownsBlock(pRunPtr));
313 if (pRunPtr == theObject)
319 NextBlock*
const p =
reinterpret_cast<NextBlock*
>(pRunPtr);
321 assert(p->isValidFor(this->m_blockSize));
323 pRunPtr = this->m_objectBlock + p->next;
#define XALAN_CPP_NAMESPACE
const size_type m_blockSize
bool ownsBlock(const ObjectType *theObject) const
ObjectType * m_objectBlock
ArenaBlockBase(MemoryManager &theManager, size_type theBlockSize)
BaseClassType::size_type size_type
ObjectType * allocateBlock()
bool shouldDestroyBlock(const ObjectType *theObject) const
ArenaBlockBase< ObjectType, SizeType > BaseClassType
ReusableArenaBlock< ObjectType, SizeType > ThisType
void destroyObject(ObjectType *theObject)
void commitAllocation(ObjectType *)
static ThisType * create(MemoryManager &theManager, size_type theBlockSize)
bool isOccupiedBlock(const ObjectType *block) const
bool ownsObject(const ObjectType *theObject) const
ReusableArenaBlock(MemoryManager &theManager, size_type theBlockSize)
Type * XalanConstruct(MemoryManager &theMemoryManager, Type *&theInstance)
bool operator==(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
void XalanDestroy(Type &theArg)
bool isValidFor(size_type rightBorder) const
const int verificationStamp
NextBlock(size_type _next)