diff options
author | Evan Huus <eapache@gmail.com> | 2013-11-04 14:12:59 +0000 |
---|---|---|
committer | Evan Huus <eapache@gmail.com> | 2013-11-04 14:12:59 +0000 |
commit | 8a0ef070007671308d69d2bb11a4393b4558ace9 (patch) | |
tree | fa5175cdd19f5f37c8cec4031c9d7ce13bbbfd10 /epan/epan.c | |
parent | ca7923f7d5fb9c393193cf7e2ad44edec40a4ef6 (diff) |
Effectively remove the tree memory pool and port some of its behaviour to the
pinfo memory pool, they have exactly the same scope. Simplification and minor
performance win (one GHashTable we longer have to create/destroy on every
packet).
svn path=/trunk/; revision=53076
Diffstat (limited to 'epan/epan.c')
-rw-r--r-- | epan/epan.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/epan/epan.c b/epan/epan.c index 7dfe3a71e9..21b38e2682 100644 --- a/epan/epan.c +++ b/epan/epan.c @@ -67,6 +67,8 @@ #include <ares_version.h> #endif +static wmem_allocator_t *pinfo_pool_cache = NULL; + const gchar* epan_get_version(void) { return VERSION; @@ -224,6 +226,15 @@ epan_dissect_init(epan_dissect_t *edt, epan_t *session, const gboolean create_pr edt->session = session; + memset(&edt->pi, 0, sizeof(edt->pi)); + if (pinfo_pool_cache != NULL) { + edt->pi.pool = pinfo_pool_cache; + pinfo_pool_cache = NULL; + } + else { + edt->pi.pool = wmem_allocator_new(WMEM_ALLOCATOR_BLOCK); + } + if (create_proto_tree) { edt->tree = proto_tree_create_root(&edt->pi); proto_tree_set_visible(edt->tree, proto_tree_visible); @@ -234,9 +245,6 @@ epan_dissect_init(epan_dissect_t *edt, epan_t *session, const gboolean create_pr edt->tvb = NULL; - memset(&edt->pi, 0, sizeof(edt->pi)); - edt->pi.pool = wmem_allocator_new(WMEM_ALLOCATOR_SIMPLE); - return edt; } @@ -334,7 +342,13 @@ epan_dissect_cleanup(epan_dissect_t* edt) proto_tree_free(edt->tree); } - wmem_destroy_allocator(edt->pi.pool); + if (pinfo_pool_cache == NULL) { + wmem_free_all(edt->pi.pool); + pinfo_pool_cache = edt->pi.pool; + } + else { + wmem_destroy_allocator(edt->pi.pool); + } } void |