From ebae0c98f8556b9533cd1bb21c4bac548ab5e470 Mon Sep 17 00:00:00 2001 From: Evan Huus Date: Fri, 3 Jul 2015 21:14:53 -0400 Subject: [PATCH] store tcp/udp port names in epan scope This causes them to be freed on shutdown, cleaning up ~800KB of "reachable" memory according to valgrind. The fact that we even need to construct these as value_strings is questionable IMHO, but that's a problem for a later date. Switch epan_scope to the BLOCK allocator now that we're using it for so much more, this gives a small but measurable increase in startup time. Change-Id: I187460b769e28da3c6629abac1d9196727ae7dde Reviewed-on: https://code.wireshark.org/review/9483 Reviewed-by: Michael Mann Reviewed-by: Evan Huus --- epan/dissectors/packet-tcp.c | 2 +- epan/dissectors/packet-udp.c | 2 +- epan/wmem/wmem_scopes.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/epan/dissectors/packet-tcp.c b/epan/dissectors/packet-tcp.c index 6ad4619b1e..8511762b31 100644 --- a/epan/dissectors/packet-tcp.c +++ b/epan/dissectors/packet-tcp.c @@ -5985,7 +5985,7 @@ proto_register_tcp(void) gbl_resolv_flags.transport_name = TRUE; for (i = 0, j = 0; i <= 65535; i++) { - const char *serv = tcp_port_to_display(NULL, i); + const char *serv = tcp_port_to_display(wmem_epan_scope(), i); if (serv) { value_string *p = &tcp_ports[j++]; diff --git a/epan/dissectors/packet-udp.c b/epan/dissectors/packet-udp.c index bb09ff71b5..2dd5a87203 100644 --- a/epan/dissectors/packet-udp.c +++ b/epan/dissectors/packet-udp.c @@ -959,7 +959,7 @@ proto_register_udp(void) gbl_resolv_flags.transport_name = TRUE; for (i = 0, j = 0; i <= 65535; i++) { - const char *serv = udp_port_to_display(NULL, i); + const char *serv = udp_port_to_display(wmem_epan_scope(), i); if (serv) { value_string *p = &udp_ports[j++]; diff --git a/epan/wmem/wmem_scopes.c b/epan/wmem/wmem_scopes.c index 7ff17870e1..5eb6ab0d37 100644 --- a/epan/wmem/wmem_scopes.c +++ b/epan/wmem/wmem_scopes.c @@ -137,7 +137,7 @@ wmem_init_scopes(void) packet_scope = wmem_allocator_new(WMEM_ALLOCATOR_BLOCK_FAST); file_scope = wmem_allocator_new(WMEM_ALLOCATOR_BLOCK); - epan_scope = wmem_allocator_new(WMEM_ALLOCATOR_SIMPLE); + epan_scope = wmem_allocator_new(WMEM_ALLOCATOR_BLOCK); /* Scopes are initialized to TRUE by default on creation */ packet_scope->in_scope = FALSE; -- 2.34.1