aboutsummaryrefslogtreecommitdiffstats
path: root/src/mem_pool.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2006-09-11 04:39:27 +0000
committerlloyd <[email protected]>2006-09-11 04:39:27 +0000
commit0d2a601dd997cbb52a853d9e428c90e1fa1c12a9 (patch)
tree4f21a9c284c32bcc4dbb7dcf843264df081bed55 /src/mem_pool.cpp
parent31170c2210d98c2ea8f3fac56ff5f31e27f741af (diff)
When searching the block list, first try the last block we had a good
allocation from, rather than the block after that one. This helps the pathalogical case where there are many full blocks and some free blocks at the very end of the list (as then it would loop through each one, trying and failing to allocate from an already full block until it hit the end of the list again).
Diffstat (limited to 'src/mem_pool.cpp')
-rw-r--r--src/mem_pool.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/mem_pool.cpp b/src/mem_pool.cpp
index 24866d172..e327b3473 100644
--- a/src/mem_pool.cpp
+++ b/src/mem_pool.cpp
@@ -244,16 +244,16 @@ byte* Pooling_Allocator::allocate_blocks(u32bit n)
do
{
- ++i;
- if(i == blocks.end())
- i = blocks.begin();
-
byte* mem = i->alloc(n);
if(mem)
{
last_used = i;
return mem;
}
+
+ ++i;
+ if(i == blocks.end())
+ i = blocks.begin();
}
while(i != last_used);