bug #26213 "Problem with memory allocation when debugging": memp_sizes contained the wrong sizes (including sanity regions); memp pools for MEM_USE_POOLS were too small; Added option MEM_USE_POOLS_TRY_BIGGER_POOL to try the next bigger malloc pool if one is empty (only usable with MEM_USE_POOLS).
This commit is contained in:
@@ -89,6 +89,14 @@ extern const u16_t memp_sizes[MEMP_MAX];
|
||||
|
||||
#else /* MEMP_MEM_MALLOC */
|
||||
|
||||
#if MEM_USE_POOLS
|
||||
/** This structure is used to save the pool one element came from. */
|
||||
struct memp_malloc_helper
|
||||
{
|
||||
memp_t poolnr;
|
||||
};
|
||||
#endif /* MEM_USE_POOLS */
|
||||
|
||||
void memp_init(void);
|
||||
|
||||
#if MEMP_OVERFLOW_CHECK
|
||||
|
||||
@@ -10,8 +10,9 @@
|
||||
* above, then will declare #2 & #3 to be just standard mempools.
|
||||
*/
|
||||
#ifndef LWIP_MALLOC_MEMPOOL
|
||||
/* This treats "malloc pools" just like any other pool */
|
||||
#define LWIP_MALLOC_MEMPOOL(num, size) LWIP_MEMPOOL(POOL_##size, num, size, "MALLOC_"#size)
|
||||
/* 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_START
|
||||
#define LWIP_MALLOC_MEMPOOL_END
|
||||
#endif /* LWIP_MALLOC_MEMPOOL */
|
||||
|
||||
@@ -149,11 +149,20 @@
|
||||
* MEM_USE_POOLS==1: Use an alternative to malloc() by allocating from a set
|
||||
* of memory pools of various sizes. When mem_malloc is called, an element of
|
||||
* the smallest pool that can provide the length needed is returned.
|
||||
* To use this, MEMP_USE_CUSTOM_POOLS also has to be enabled.
|
||||
*/
|
||||
#ifndef MEM_USE_POOLS
|
||||
#define MEM_USE_POOLS 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MEM_USE_POOLS_TRY_BIGGER_POOL==1: if one malloc-pool is empty, try the next
|
||||
* bigger pool - WARNING: THIS MIGHT WASTE MEMORY but it can make a system more
|
||||
* reliable. */
|
||||
#ifndef MEM_USE_POOLS_TRY_BIGGER_POOL
|
||||
#define MEM_USE_POOLS_TRY_BIGGER_POOL 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MEMP_USE_CUSTOM_POOLS==1: whether to include a user file lwippools.h
|
||||
* that defines additional pools beyond the "standard" ones required
|
||||
|
||||
Reference in New Issue
Block a user