mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-11-18 20:10:53 +00:00
Fixed size calculation in MALLOC memory pool creation macro.
The LWIP_MALLOC_MEMPOOL macro needs to use the aligned size of the memp_malloc_helper structure, since mem_alloc() uses it to calculate the required pool element size. If LWIP_MEM_ALIGN_SIZE(x) is redefined to align to something larger than 4, then in some cases the current code can lead to unexpected mem_alloc() failures. For example: #define LWIP_MEM_ALIGN_SIZE(size) (((size) + 31) & ~31) and the largest MALLOC pool is of size 60 bytes, e.g.: #define LWIP_MALLOC_MEMPOOL(256, 60) then the following call: mem_malloc(58) will cause an assertion.
This commit is contained in:
parent
a70567e74f
commit
38bfe50508
@ -12,7 +12,7 @@
|
||||
#ifndef LWIP_MALLOC_MEMPOOL
|
||||
/* This treats "malloc pools" just like any other pool.
|
||||
The pools are a little bigger to provide 'size' as the amount of user data. */
|
||||
#define LWIP_MALLOC_MEMPOOL(num, size) LWIP_MEMPOOL(POOL_##size, num, (size + sizeof(struct memp_malloc_helper)), "MALLOC_"#size)
|
||||
#define LWIP_MALLOC_MEMPOOL(num, size) LWIP_MEMPOOL(POOL_##size, num, (size + LWIP_MEM_ALIGN_SIZE(sizeof(struct memp_malloc_helper))), "MALLOC_"#size)
|
||||
#define LWIP_MALLOC_MEMPOOL_START
|
||||
#define LWIP_MALLOC_MEMPOOL_END
|
||||
#endif /* LWIP_MALLOC_MEMPOOL */
|
||||
|
Loading…
Reference in New Issue
Block a user