Skip to content

Commit e39aeff

Browse files
authored
Merge pull request #10706 from hugueskamba/fix-softcoding-mem-pool-size-evaluation
mem pool size: Fix calculation of memory pool size for portability
2 parents 34eefb4 + 4f8305e commit e39aeff

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

rtos/MemoryPool.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,11 @@ class MemoryPool : private mbed::NonCopyable<MemoryPool<T, pool_sz> > {
183183

184184
private:
185185
osMemoryPoolId_t _id;
186-
/* osMemoryPoolNew requires that pool block size is a multiple of 4 bytes. */
187-
char _pool_mem[((sizeof(T) + 3) & ~3) * pool_sz];
186+
char _pool_mem[MBED_RTOS_STORAGE_MEM_POOL_MEM_SIZE(pool_sz, sizeof(T))];
188187
mbed_rtos_storage_mem_pool_t _obj_mem;
189188
};
190189
/** @}*/
191190
/** @}*/
192191

193192
}
194193
#endif
195-
196-

rtos/TARGET_CORTEX/mbed_rtos_storage.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ typedef osRtxEventFlags_t mbed_rtos_storage_event_flags_t;
5252
typedef osRtxMessage_t mbed_rtos_storage_message_t;
5353
typedef osRtxTimer_t mbed_rtos_storage_timer_t;
5454

55+
#define MBED_RTOS_STORAGE_MEM_POOL_MEM_SIZE(block_count, block_size) \
56+
osRtxMemoryPoolMemSize(block_count, block_size)
57+
5558
#ifdef __cplusplus
5659
}
5760
#endif

0 commit comments

Comments
 (0)