store tcp/udp port names in epan scope
authorEvan Huus <eapache@gmail.com>
Sat, 4 Jul 2015 01:14:53 +0000 (21:14 -0400)
committerEvan Huus <eapache@gmail.com>
Sat, 4 Jul 2015 12:21:34 +0000 (12:21 +0000)
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 <mmann78@netscape.net>
Reviewed-by: Evan Huus <eapache@gmail.com>
epan/dissectors/packet-tcp.c
epan/dissectors/packet-udp.c
epan/wmem/wmem_scopes.c

index 6ad4619b1ee948b255b46aeb39dbeb9831d5101d..8511762b316e6bd4d411714480f656d963262c19 100644 (file)
@@ -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++];
index bb09ff71b5b8e6f9a94664fa477cf2ede15db0ce..2dd5a8720307f999ce1ada7b26dc3d0afae5d9ef 100644 (file)
@@ -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++];
index 7ff17870e1ea306c0e4bfbe9074428bf201c46be..5eb6ab0d37a84e00ca72f6da015729cd6b539603 100644 (file)
@@ -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;