diff options
author | Dario Lombardo <lomato@gmail.com> | 2018-01-16 17:45:02 +0100 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2018-01-22 04:58:40 +0000 |
commit | 4d639b6f0e78602678c59a0d6270d89835f3980e (patch) | |
tree | 8fc25081a264c819e5b9c918f20ffe43287e369f /ui | |
parent | f0e1faac66b94f162a47623dc2ee1673ad0c7606 (diff) |
tap-httpstat: cast memory instead of reallocate it in glib hash table.
Change-Id: I74db1247f15bdd12fb3ef7fa258d0018605caa30
Reviewed-on: https://code.wireshark.org/review/25346
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'ui')
-rw-r--r-- | ui/cli/tap-httpstat.c | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/ui/cli/tap-httpstat.c b/ui/cli/tap-httpstat.c index ec4d8e732f..75bf5ff23a 100644 --- a/ui/cli/tap-httpstat.c +++ b/ui/cli/tap-httpstat.c @@ -141,18 +141,16 @@ http_init_hash(httpstat_t *sp) { int i; - sp->hash_responses = g_hash_table_new(g_int_hash, g_int_equal); + sp->hash_responses = g_hash_table_new(g_direct_hash, g_direct_equal); for (i=0; vals_status_code[i].strptr; i++ ) { - gint *key = g_new (gint, 1); http_response_code_t *sc = g_new (http_response_code_t, 1); - *key = vals_status_code[i].value; sc->packets = 0; - sc->response_code = *key; + sc->response_code = vals_status_code[i].value; sc->name = vals_status_code[i].strptr; sc->sp = sp; - g_hash_table_insert(sc->sp->hash_responses, key, sc); + g_hash_table_insert(sc->sp->hash_responses, GUINT_TO_POINTER(vals_status_code[i].value), sc); } sp->hash_requests = g_hash_table_new(g_str_hash, g_str_equal); } @@ -218,13 +216,12 @@ httpstat_packet(void *psp , packet_info *pinfo _U_, epan_dissect_t *edt _U_, con /* We are only interested in reply packets with a status code */ /* Request or reply packets ? */ if (value->response_code != 0) { - guint *key = g_new(guint, 1); http_response_code_t *sc; + guint key = value->response_code; - *key = value->response_code; sc = (http_response_code_t *)g_hash_table_lookup( sp->hash_responses, - key); + GUINT_TO_POINTER(key)); if (sc == NULL) { /* non standard status code ; we classify it as others * in the relevant category (Informational,Success,Redirection,Client Error,Server Error) @@ -234,23 +231,23 @@ httpstat_packet(void *psp , packet_info *pinfo _U_, epan_dissect_t *edt _U_, con return 0; } else if (i < 200) { - *key = 199; /* Hopefully, this status code will never be used */ + key = 199; /* Hopefully, this status code will never be used */ } else if (i < 300) { - *key = 299; + key = 299; } else if (i < 400) { - *key = 399; + key = 399; } else if (i < 500) { - *key = 499; + key = 499; } else{ - *key = 599; + key = 599; } sc = (http_response_code_t *)g_hash_table_lookup( sp->hash_responses, - key); + GUINT_TO_POINTER(key)); if (sc == NULL) return 0; } |