diff options
author | Luis Ontanon <luis.ontanon@gmail.com> | 2005-03-21 15:40:33 +0000 |
---|---|---|
committer | Luis Ontanon <luis.ontanon@gmail.com> | 2005-03-21 15:40:33 +0000 |
commit | 3af24ce10a37b7778d42a1cd91482f4015a9c205 (patch) | |
tree | a9482b9f7b3c2d8b4a1c07176c558954dcaa1358 /epan | |
parent | 9e7a393c1f52980cc16890a8b18546cdabda3dc6 (diff) |
Add a cleanup call-back to the stats_tree.
svn path=/trunk/; revision=13851
Diffstat (limited to 'epan')
-rw-r--r-- | epan/stats_tree.c | 20 | ||||
-rw-r--r-- | epan/stats_tree.h | 6 | ||||
-rw-r--r-- | epan/stats_tree_priv.h | 2 |
3 files changed, 23 insertions, 5 deletions
diff --git a/epan/stats_tree.c b/epan/stats_tree.c index 22251d63cb..5bdafaf5ed 100644 --- a/epan/stats_tree.c +++ b/epan/stats_tree.c @@ -182,7 +182,10 @@ extern void stats_tree_free(stats_tree* st) { if (st->cfg->free_tree_pr) st->cfg->free_tree_pr(st); - + + if (st->cfg->cleanup) + st->cfg->cleanup(st); + g_free(st); } @@ -238,7 +241,8 @@ extern void stats_tree_register(guint8* tapname, guint8* abbr, guint8* name, stat_tree_packet_cb packet, - stat_tree_init_cb init ) { + stat_tree_init_cb init, + stat_tree_cleanup_cb cleanup) { stats_tree_cfg* cfg = g_malloc( sizeof(stats_tree_cfg) ); @@ -251,6 +255,7 @@ extern void stats_tree_register(guint8* tapname, cfg->packet = packet; cfg->init = init; + cfg->cleanup = cleanup; /* these have to be filled in by implementations */ cfg->setup_node_pr = NULL; @@ -356,7 +361,16 @@ extern void stats_tree_presentation(void (*registry_iterator)(gpointer,gpointer, void (*draw_tree)(stats_tree*), void (*reset_tree)(stats_tree*), void* data) { - struct _stats_tree_pres_cbs d = {setup_node_pr,free_node_pr,draw_node,reset_node,new_tree_pr,free_tree_pr,draw_tree,reset_tree}; + static struct _stats_tree_pres_cbs d; + + d.setup_node_pr = setup_node_pr; + d.new_tree_pr = new_tree_pr; + d.free_node_pr = free_node_pr; + d.free_tree_pr = free_tree_pr; + d.draw_node = draw_node; + d.draw_tree = draw_tree; + d.reset_node = reset_node; + d.reset_tree = reset_tree; if (registry) g_hash_table_foreach(registry,setup_tree_presentation,&d); diff --git a/epan/stats_tree.h b/epan/stats_tree.h index 557984b362..74869e836e 100644 --- a/epan/stats_tree.h +++ b/epan/stats_tree.h @@ -46,6 +46,9 @@ typedef int (*stat_tree_packet_cb)(stats_tree*, /* stats_tree initilaization callback */ typedef void (*stat_tree_init_cb)(stats_tree*); +/* stats_tree initilaization callback */ +typedef void (*stat_tree_cleanup_cb)(stats_tree*); + /* registers a new stats tree * abbr: protocol abbr * name: protocol name @@ -56,7 +59,8 @@ extern void stats_tree_register(guint8* tapname, guint8* abbr, guint8* name, stat_tree_packet_cb packet, - stat_tree_init_cb init ); + stat_tree_init_cb init, + stat_tree_cleanup_cb cleanup); extern int stats_tree_parent_id_by_name(stats_tree* st, const gchar* parent_name); diff --git a/epan/stats_tree_priv.h b/epan/stats_tree_priv.h index 0091302f4d..cbe40b30d6 100644 --- a/epan/stats_tree_priv.h +++ b/epan/stats_tree_priv.h @@ -115,7 +115,7 @@ struct _stats_tree_cfg { /* dissector defined callbacks */ stat_tree_packet_cb packet; stat_tree_init_cb init; - + stat_tree_cleanup_cb cleanup; /* * node presentation callbacks |