Asserts on free and alloc

This commit is contained in:
CarlWachter 2023-09-23 11:02:35 +02:00
parent f813e7b6ea
commit 7c8cf2e1e2
3 changed files with 12 additions and 4 deletions

5
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,5 @@
{
"files.associations": {
"*.tpp": "cpp"
}
}

View File

@ -49,7 +49,7 @@ namespace sta
*
* @param block names the block to free.
*/
osStatus_t free(void *block);
void free(void *block);
private:
osMemoryPoolId_t handle_; /**< CMSIS RTOS2 queue handle */

View File

@ -26,13 +26,16 @@ namespace sta
template <typename T>
void * RtosMemPool<T>::alloc(uint32_t timeout /* = osWaitForever */)
{
return osMemoryPoolAlloc(handle_, timeout);
void * addr = osMemoryPoolAlloc(handle_, timeout)
STA_ASSERT_MSG(addr != nullptr, "Failed to Alloc RtosMemPool Block");
return addr;
}
template <typename T>
osStatus_t RtosMemPool<T>::free(void * block)
void RtosMemPool<T>::free(void * block)
{
return osMemoryPoolFree(handle_, block);
STA_ASSERT_MSG(osMemoryPoolFree(handle_, block) == osOK,
"Failed to Free RtosMemPool Block");
}
} // namespace sta