added hook LWIP_HOOK_MEMP_AVAILABLE() to get informed when a memp pool was empty and an item is now available

This commit is contained in:
sg 2015-02-13 21:53:55 +01:00
parent 6ef7563f53
commit b5b5844119
3 changed files with 23 additions and 3 deletions

View File

@ -6,6 +6,10 @@ HISTORY
++ New features: ++ New features:
2015-02-13: Simon Goldschmidt
* opt.h, memp.c: added hook LWIP_HOOK_MEMP_AVAILABLE() to get informed when
a memp pool was empty and an item is now available
2015-02-13: Simon Goldschmidt 2015-02-13: Simon Goldschmidt
* opt.h, pbuf.h/.c, etharp.c: Added the option PBUF_LINK_ENCAPSULATION_HLEN to * opt.h, pbuf.h/.c, etharp.c: Added the option PBUF_LINK_ENCAPSULATION_HLEN to
allocate additional header space for TX on netifs requiring additional headers allocate additional header space for TX on netifs requiring additional headers

View File

@ -454,6 +454,9 @@ void
memp_free(memp_t type, void *mem) memp_free(memp_t type, void *mem)
{ {
struct memp *memp; struct memp *memp;
#ifdef LWIP_HOOK_MEMP_AVAILABLE
struct memp *old_first;
#endif
SYS_ARCH_DECL_PROTECT(old_level); SYS_ARCH_DECL_PROTECT(old_level);
if (mem == NULL) { if (mem == NULL) {
@ -477,6 +480,9 @@ memp_free(memp_t type, void *mem)
MEMP_STATS_DEC(used, type); MEMP_STATS_DEC(used, type);
memp->next = memp_tab[type]; memp->next = memp_tab[type];
#ifdef LWIP_HOOK_MEMP_AVAILABLE
old_first = memp_tab[type];
#endif
memp_tab[type] = memp; memp_tab[type] = memp;
#if MEMP_SANITY_CHECK #if MEMP_SANITY_CHECK
@ -484,6 +490,11 @@ memp_free(memp_t type, void *mem)
#endif /* MEMP_SANITY_CHECK */ #endif /* MEMP_SANITY_CHECK */
SYS_ARCH_UNPROTECT(old_level); SYS_ARCH_UNPROTECT(old_level);
#ifdef LWIP_HOOK_MEMP_AVAILABLE
if (old_first == NULL) {
LWIP_HOOK_MEMP_AVAILABLE(type);
}
#endif
} }
#endif /* MEMP_MEM_MALLOC */ #endif /* MEMP_MEM_MALLOC */

View File

@ -2547,6 +2547,11 @@
* Hook can be used to set prio_vid field of vlan_hdr. * Hook can be used to set prio_vid field of vlan_hdr.
*/ */
/**
* LWIP_HOOK_MEMP_AVAILABLE(memp_t_type):
* - called from memp_free() when a memp pool was empty and an item is now available
*/
/* /*
--------------------------------------- ---------------------------------------
---------- Debugging options ---------- ---------- Debugging options ----------