About how to use the mem pool in internal of lwip (sorry for last mis-sending email)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

About how to use the mem pool in internal of lwip (sorry for last mis-sending email)

lwip-users mailing list
Hi all,

I am currently transiting my project from memory heap to memory pool.

I have defined MEM_USE_POOLS and MEMP_USE_CUSTOM_POOLS to 1. Add lwippools.h as follows:
LWIP_MALLOC_MEMPOOL_START
LWIP_MALLOC_MEMPOOL(20, 256)
LWIP_MALLOC_MEMPOOL_END

Therefore, the memp_t will be as follows
typedef enum {
  MEMP_RAW_PCB,
  MEMP_UDP_PCB,
  ...
  MEMP_MLD6_GROUP,
  MEMP_PBUF,
  MEMP_PBUF_POOL,
  MEMP_POOL_256,
  MEMP_MAX
} memp_t;

When lwip call pbuf_alloc in mld6_send as follows, mem_malloc will be called.
p = pbuf_alloc(PBUF_IP, sizeof(struct mld_header) + MLD6_HBH_HLEN, PBUF_RAM);

However, mem_malloc (under #elif MEM_USE_POOLS) in mem.c will allocate a MEMP_POOL_256 rather than MEMP_PBUF_POOL. Since MEMP_POOL_FIRST is MEMP_POOL_256 and the size is big enough.

I originally thought mem_malloc should allocate a MEMP_PBUF_POOL rather than MEMP_POOL_256. Is there anything I misunderstood? Is there a memory pool use example to reference or any material to discuss the memory pool usage?

Regards,
York

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users