Browse Source

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

STABLE-2_1_x
sg 11 years ago
parent
commit
b5b5844119
  1. 4
      CHANGELOG
  2. 17
      src/core/memp.c
  3. 5
      src/include/lwip/opt.h

4
CHANGELOG

@ -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

17
src/core/memp.c

@ -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 */

5
src/include/lwip/opt.h

@ -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 ----------

Loading…
Cancel
Save