ansi_map: create and populate the stats table only once

Use the new stat_tap_find_table function during init to check if our
statistics table already exists.

If so, we can safely assume that its rows have already beend initialized.
All we have to do is clear the data that was collected by the tap.
This commit is contained in:
Martin Kaiser 2021-02-06 15:04:20 +01:00 committed by Wireshark GitLab Utility
parent 04d887f2fd
commit a198094599
2 changed files with 24 additions and 4 deletions

View File

@ -4437,11 +4437,21 @@ static stat_tap_table_item stat_fields[] = {{TABLE_ITEM_UINT, TAP_ALIGN_RIGHT, "
static void ansi_map_stat_init(stat_tap_table_ui* new_stat)
{
const char *table_name = "ANSI MAP Operation Statistics";
int num_fields = sizeof(stat_fields)/sizeof(stat_tap_table_item);
stat_tap_table* table = stat_tap_init_table("ANSI MAP Operation Statistics", num_fields, 0, "ansi_map.op_code");
stat_tap_table *table;
int i = 0;
stat_tap_table_item_type items[sizeof(stat_fields)/sizeof(stat_tap_table_item)];
table = stat_tap_find_table(new_stat, table_name);
if (table) {
if (new_stat->stat_tap_reset_table_cb) {
new_stat->stat_tap_reset_table_cb(table);
}
return;
}
table = stat_tap_init_table(table_name, num_fields, 0, "ansi_map.op_code");
stat_tap_add_table(new_stat, table);
/* Add a fow for each value type */

View File

@ -16086,11 +16086,21 @@ static stat_tap_table_item stat_fields[] = {{TABLE_ITEM_UINT, TAP_ALIGN_RIGHT, "
static void ansi_map_stat_init(stat_tap_table_ui* new_stat)
{
const char *table_name = "ANSI MAP Operation Statistics";
int num_fields = sizeof(stat_fields)/sizeof(stat_tap_table_item);
stat_tap_table* table = stat_tap_init_table("ANSI MAP Operation Statistics", num_fields, 0, "ansi_map.op_code");
stat_tap_table *table;
int i = 0;
stat_tap_table_item_type items[sizeof(stat_fields)/sizeof(stat_tap_table_item)];
table = stat_tap_find_table(new_stat, table_name);
if (table) {
if (new_stat->stat_tap_reset_table_cb) {
new_stat->stat_tap_reset_table_cb(table);
}
return;
}
table = stat_tap_init_table(table_name, num_fields, 0, "ansi_map.op_code");
stat_tap_add_table(new_stat, table);
/* Add a fow for each value type */
@ -19199,7 +19209,7 @@ void proto_register_ansi_map(void) {
NULL, HFILL }},
/*--- End of included file: packet-ansi_map-hfarr.c ---*/
#line 5361 "./asn1/ansi_map/packet-ansi_map-template.c"
#line 5371 "./asn1/ansi_map/packet-ansi_map-template.c"
};
/* List of subtrees */
@ -19460,7 +19470,7 @@ void proto_register_ansi_map(void) {
&ett_ansi_map_ReturnData,
/*--- End of included file: packet-ansi_map-ettarr.c ---*/
#line 5394 "./asn1/ansi_map/packet-ansi_map-template.c"
#line 5404 "./asn1/ansi_map/packet-ansi_map-template.c"
};
static ei_register_info ei[] = {