From c1ed1866a4d41e113573a6eaf521912244e4642d Mon Sep 17 00:00:00 2001 From: rubidium Date: Thu, 30 Oct 2008 12:32:32 +0000 Subject: (svn r14547) -Fix: order pool seemed to look full when it was not as it only checked whether it was possible to allocate a new block of pool items instead of checking for free pool items. --- src/oldpool_func.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/oldpool_func.h') diff --git a/src/oldpool_func.h b/src/oldpool_func.h index 8a26adc22..fc08bf9ee 100644 --- a/src/oldpool_func.h +++ b/src/oldpool_func.h @@ -38,19 +38,21 @@ template *Tpool> T *PoolItem *Tpool> bool PoolItem::CanAllocateItem() +template *Tpool> bool PoolItem::CanAllocateItem(uint count) { uint last_minus_one = Tpool->GetSize() - 1; - for (T *t = Tpool->Get(Tpool->first_free_index); t != NULL; t = ((uint)t->index < last_minus_one) ? Tpool->Get(t->index + 1U) : NULL) { - if (!t->IsValid()) return true; - Tpool->first_free_index = t->index; + for (T *t = Tpool->Get(Tpool->first_free_index); count > 0 && t != NULL; t = ((uint)t->index < last_minus_one) ? Tpool->Get(t->index + 1U) : NULL) { + if (!t->IsValid()) count--; } + if (count == 0) return true; + /* Check if we can add a block to the pool */ - if (Tpool->AddBlockToPool()) return CanAllocateItem(); + if (Tpool->AddBlockToPool()) return CanAllocateItem(count); return false; } -- cgit v1.2.3-54-g00ecf