mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-13 20:53:34 +08:00
Allocator fixes
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user