diff --git a/rtos/MemoryPool.h b/rtos/MemoryPool.h index 02c34bdcd4..431b5d6894 100644 --- a/rtos/MemoryPool.h +++ b/rtos/MemoryPool.h @@ -183,8 +183,7 @@ public: private: osMemoryPoolId_t _id; - /* osMemoryPoolNew requires that pool block size is a multiple of 4 bytes. */ - char _pool_mem[((sizeof(T) + 3) & ~3) * pool_sz]; + char _pool_mem[MBED_RTOS_STORAGE_MEM_POOL_MEM_SIZE(pool_sz, sizeof(T))]; mbed_rtos_storage_mem_pool_t _obj_mem; }; /** @}*/ @@ -192,5 +191,3 @@ private: } #endif - - diff --git a/rtos/TARGET_CORTEX/mbed_rtos_storage.h b/rtos/TARGET_CORTEX/mbed_rtos_storage.h index 66c1d07808..2a0338baed 100644 --- a/rtos/TARGET_CORTEX/mbed_rtos_storage.h +++ b/rtos/TARGET_CORTEX/mbed_rtos_storage.h @@ -52,6 +52,9 @@ typedef osRtxEventFlags_t mbed_rtos_storage_event_flags_t; typedef osRtxMessage_t mbed_rtos_storage_message_t; typedef osRtxTimer_t mbed_rtos_storage_timer_t; +#define MBED_RTOS_STORAGE_MEM_POOL_MEM_SIZE(block_count, block_size) \ + osRtxMemoryPoolMemSize(block_count, block_size) + #ifdef __cplusplus } #endif