diff options
author | Kovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com> | 2009-08-13 19:42:46 +0000 |
---|---|---|
committer | Kovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com> | 2009-08-13 19:42:46 +0000 |
commit | 80a6d3fbcf1d8ee469fbdb6c2d6423f942cbe712 (patch) | |
tree | 41a0430751c01d746062340b6b29c96147592b9f /epan/epan.c | |
parent | 97fda7386c87b840410a1804feee134ab0572276 (diff) |
Introduce epan_dissect_init()/epan_dissect_cleanup(). These are used to initialise/cleanup stack allocated 'edt' structures. This should speed up dissection since we avoid some malloc traffic.
svn path=/trunk/; revision=29404
Diffstat (limited to 'epan/epan.c')
-rw-r--r-- | epan/epan.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/epan/epan.c b/epan/epan.c index 7c088914d3..623865e561 100644 --- a/epan/epan.c +++ b/epan/epan.c @@ -145,11 +145,9 @@ epan_circuit_init(void) } epan_dissect_t* -epan_dissect_new(gboolean create_proto_tree, gboolean proto_tree_visible) +epan_dissect_init(epan_dissect_t *edt, gboolean create_proto_tree, gboolean proto_tree_visible) { - epan_dissect_t *edt; - - edt = g_new(epan_dissect_t, 1); + g_assert(edt); if (create_proto_tree) { edt->tree = proto_tree_create_root(); @@ -162,6 +160,16 @@ epan_dissect_new(gboolean create_proto_tree, gboolean proto_tree_visible) return edt; } +epan_dissect_t* +epan_dissect_new(gboolean create_proto_tree, gboolean proto_tree_visible) +{ + epan_dissect_t *edt; + + edt = g_new(epan_dissect_t, 1); + + return epan_dissect_init(edt, create_proto_tree, proto_tree_visible); +} + void epan_dissect_fake_protocols(epan_dissect_t *edt, gboolean fake_protocols) { @@ -179,10 +187,11 @@ epan_dissect_run(epan_dissect_t *edt, void* pseudo_header, dissect_packet(edt, pseudo_header, data, fd, cinfo); } - void -epan_dissect_free(epan_dissect_t* edt) +epan_dissect_cleanup(epan_dissect_t* edt) { + g_assert(edt); + /* Free the data sources list. */ free_data_sources(&edt->pi); @@ -194,7 +203,12 @@ epan_dissect_free(epan_dissect_t* edt) if (edt->tree) { proto_tree_free(edt->tree); } +} +void +epan_dissect_free(epan_dissect_t* edt) +{ + epan_dissect_cleanup(edt); g_free(edt); } |