mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-01 13:21:37 +08:00
Proper destruction of DynamicTransferBuffer
This commit is contained in:
@@ -96,6 +96,11 @@ public:
|
||||
IsDynamicallyAllocatable<DynamicTransferBuffer>::check();
|
||||
}
|
||||
|
||||
~DynamicTransferBuffer()
|
||||
{
|
||||
resetImpl();
|
||||
}
|
||||
|
||||
int read(unsigned int offset, uint8_t* data, unsigned int len) const;
|
||||
int write(unsigned int offset, const uint8_t* data, unsigned int len);
|
||||
};
|
||||
|
||||
@@ -183,8 +183,8 @@ TEST(DynamicTransferBuffer, Basic)
|
||||
ASSERT_EQ(21, buf.write(0, test_data_ptr, 21));
|
||||
ASSERT_TRUE(matchAgainstTestData(buf, 0));
|
||||
|
||||
// Reset
|
||||
// Destroying the object; memory should be released
|
||||
ASSERT_LT(0, pool.getNumUsedBlocks());
|
||||
buf.reset();
|
||||
buf.~DynamicTransferBuffer();
|
||||
ASSERT_EQ(0, pool.getNumUsedBlocks());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user