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:
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
* 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

View File

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

View File

@ -2547,6 +2547,11 @@
* 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 ----------