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>
54 enum { VALID_OBJECT_STAMP = 0xffddffdd };
61 verificationStamp(VALID_OBJECT_STAMP)
68 return ( ( verificationStamp ==
int(VALID_OBJECT_STAMP)) &&
101 i < this->m_blockSize &&
105 if ( isOccupiedBlock(&this->m_objectBlock[
i]) )
107 this->m_objectBlock[
i].~ObjectType();
137 if ( this->m_objectCount == this->m_blockSize )
139 assert ( this->m_firstFreeBlock == (this->m_blockSize + 1) );
153 if(this->m_firstFreeBlock != this->m_nextFreeBlock)
156 theResult = this->m_objectBlock + this->m_firstFreeBlock;
160 theResult = this->m_objectBlock + this->m_firstFreeBlock;
167 this->m_nextFreeBlock =
theBlock->next;
172 ++this->m_objectCount;
189 this->m_firstFreeBlock = this->m_nextFreeBlock;
205 if ( this->m_firstFreeBlock != this->m_nextFreeBlock )
208 void*
const p = this->m_objectBlock + this->m_firstFreeBlock;
212 this->m_nextFreeBlock = this->m_firstFreeBlock;
223 this->m_nextFreeBlock =
228 --this->m_objectCount;
272 return !(this->ownsBlock(
block) &&
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
Xalan-C++ namespace, including major and minor version.
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)