@@ -231,28 +231,20 @@ struct PoolItem {
*/
virtual bool IsValid() const
{
return false;
}
protected:
/**
* Allocate a pool item; possibly allocate a new block in the pool.
* @return the allocated pool item (or NULL when the pool is full).
static inline T *AllocateRaw()
return AllocateRaw(Tpool->first_free_index);
private:
* @param first the first pool item to start searching
* @pre first <= Tpool->GetSize()
static inline T *AllocateRaw(uint &first)
static inline T *AllocateSafeRaw(uint &first)
uint last_minus_one = Tpool->GetSize() - 1;
for (T *t = Tpool->Get(first); t != NULL; t = (t->index < last_minus_one) ? Tpool->Get(t->index + 1U) : NULL) {
if (!t->IsValid()) {
first = t->index;
@@ -267,12 +259,34 @@ protected:
/* Check if we can add a block to the pool */
if (Tpool->AddBlockToPool()) return AllocateRaw(first);
return NULL;
return AllocateSafeRaw(Tpool->first_free_index);
if (first >= Tpool->GetSize() && !Tpool->AddBlockToPool()) return NULL;
return AllocateSafeRaw(first);
* Are we cleaning this pool?
* @return true if we are
static inline bool CleaningPool()
Status change: