From c221361874b871ea8fa84a6e920235343ed5928c Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Thu, 14 Jan 2016 15:18:57 +0800 Subject: [PATCH] stats: Move memp_names table out of stats_init/stats_display_memp functions This makes the code simpler with better readability. Also make memp_names static because it's only referenced by stats.c. Signed-off-by: Axel Lin --- src/core/stats.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/core/stats.c b/src/core/stats.c index 43734cee..6e32faeb 100644 --- a/src/core/stats.c +++ b/src/core/stats.c @@ -49,15 +49,18 @@ struct stats_ lwip_stats; +#if MEMP_STATS +static const char * memp_names[] = { +#define LWIP_MEMPOOL(name,num,size,desc) desc, +#include "lwip/priv/memp_std.h" +}; +#endif /* MEMP_STATS */ + void stats_init(void) { #ifdef LWIP_DEBUG #if MEMP_STATS - const char * memp_names[] = { -#define LWIP_MEMPOOL(name,num,size,desc) desc, -#include "lwip/priv/memp_std.h" - }; int i; for (i = 0; i < MEMP_MAX; i++) { lwip_stats.memp[i].name = memp_names[i]; @@ -125,10 +128,6 @@ stats_display_mem(struct stats_mem *mem, const char *name) void stats_display_memp(struct stats_mem *mem, int index) { - const char * memp_names[] = { -#define LWIP_MEMPOOL(name,num,size,desc) desc, -#include "lwip/priv/memp_std.h" - }; if (index < MEMP_MAX) { stats_display_mem(mem, memp_names[index]); }