Allocator fixes

This commit is contained in:
Pavel Kirienko
2014-04-12 17:50:32 +04:00
parent 6f1affa51f
commit 3e4234e049
2 changed files with 3 additions and 1 deletions
+1 -1
View File
@@ -45,7 +45,7 @@ std::size_t LimitedPoolAllocator::getBlockSize() const
std::size_t LimitedPoolAllocator::getNumBlocks() const
{
return allocator_.getNumBlocks();
return std::min(max_blocks_, allocator_.getNumBlocks());
}
}
+2
View File
@@ -100,6 +100,8 @@ TEST(DynamicMemory, LimitedPoolAllocator)
uavcan::PoolAllocator<128, 32> pool32;
uavcan::LimitedPoolAllocator lim(pool32, 2);
EXPECT_EQ(2, lim.getNumBlocks());
const void* ptr1 = lim.allocate(1);
const void* ptr2 = lim.allocate(1);
const void* ptr3 = lim.allocate(1);