diff --git a/CHANGELOG b/CHANGELOG index ab2b536b..2e4c3be0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -13,6 +13,10 @@ HISTORY ++ New features: + 2010-02-21: Simon Goldschmidt + * stats.c/.h: Added const char* name to mem- and memp-stats for easier + debugging. + 2010-02-21: Simon Goldschmidt * tcp.h (and usages), added tcp_impl.h: Splitted API and internal implementation of tcp to make API usage cleare to application programmers diff --git a/src/core/stats.c b/src/core/stats.c index bf192d29..bd252724 100644 --- a/src/core/stats.c +++ b/src/core/stats.c @@ -48,6 +48,25 @@ struct stats_ lwip_stats; +void stats_init() +{ +#ifdef LWIP_DEBUG +#if MEMP_STATS + char * memp_names[] = { +#define LWIP_MEMPOOL(name,num,size,desc) desc, +#include "lwip/memp_std.h" + }; + int i; + for (i = 0; i < MEMP_MAX; i++) { + lwip_stats.memp[i].name = memp_names[i]; + } +#endif /* MEMP_STATS */ +#if MEM_STATS + lwip_stats.mem.name = "MEM"; +#endif /* MEM_STATS */ +#endif /* LWIP_DEBUG */ +} + #if LWIP_STATS_DISPLAY void stats_display_proto(struct stats_proto *proto, char *name) diff --git a/src/include/lwip/stats.h b/src/include/lwip/stats.h index c34555ac..d82e1810 100644 --- a/src/include/lwip/stats.h +++ b/src/include/lwip/stats.h @@ -88,6 +88,9 @@ struct stats_igmp { }; struct stats_mem { +#ifdef LWIP_DEBUG + const char *name; +#endif /* LWIP_DEBUG */ mem_size_t avail; mem_size_t used; mem_size_t max; @@ -145,7 +148,7 @@ struct stats_ { extern struct stats_ lwip_stats; -#define stats_init() /* Compatibility define, no init needed. */ +void stats_init(); #define STATS_INC(x) ++lwip_stats.x #define STATS_DEC(x) --lwip_stats.x