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
This commit is contained in:
parent
ca7923f7d5
commit
8a0ef07000
22
epan/epan.c
22
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
|
||||
|
|
25
epan/proto.c
25
epan/proto.c
|
@ -252,8 +252,6 @@ struct _protocol {
|
|||
/* List of all protocols */
|
||||
static GList *protocols = NULL;
|
||||
|
||||
static wmem_allocator_t *tree_pool_cache = NULL;
|
||||
|
||||
/* Contains information about a field when a dissector calls
|
||||
* proto_tree_add_item. */
|
||||
#define FIELD_INFO_NEW(pool, fi) fi = wmem_new(pool, field_info)
|
||||
|
@ -573,8 +571,6 @@ proto_tree_reset(proto_tree *tree)
|
|||
/* Reset track of the number of children */
|
||||
tree_data->count = 0;
|
||||
|
||||
wmem_free_all(tree_data->mem_pool);
|
||||
|
||||
PROTO_NODE_INIT(tree);
|
||||
}
|
||||
|
||||
|
@ -582,7 +578,6 @@ proto_tree_reset(proto_tree *tree)
|
|||
void
|
||||
proto_tree_free(proto_tree *tree)
|
||||
{
|
||||
wmem_allocator_t *pool = PNODE_POOL(tree);
|
||||
tree_data_t *tree_data = PTREE_DATA(tree);
|
||||
|
||||
proto_tree_children_foreach(tree, proto_tree_free_node, NULL);
|
||||
|
@ -597,15 +592,6 @@ proto_tree_free(proto_tree *tree)
|
|||
g_hash_table_destroy(tree_data->interesting_hfids);
|
||||
}
|
||||
|
||||
if (tree_pool_cache) {
|
||||
/* if we already have one cached then just destroy it */
|
||||
wmem_destroy_allocator(pool);
|
||||
}
|
||||
else {
|
||||
wmem_free_all(pool);
|
||||
tree_pool_cache = pool;
|
||||
}
|
||||
|
||||
g_slice_free(tree_data_t, tree_data);
|
||||
|
||||
g_slice_free(proto_tree, tree);
|
||||
|
@ -4090,17 +4076,8 @@ proto_item_get_len(const proto_item *pi)
|
|||
proto_tree *
|
||||
proto_tree_create_root(packet_info *pinfo)
|
||||
{
|
||||
wmem_allocator_t *pool;
|
||||
proto_node *pnode;
|
||||
|
||||
if (tree_pool_cache) {
|
||||
pool = tree_pool_cache;
|
||||
tree_pool_cache = NULL;
|
||||
}
|
||||
else {
|
||||
pool = wmem_allocator_new(WMEM_ALLOCATOR_BLOCK);
|
||||
}
|
||||
|
||||
/* Initialize the proto_node */
|
||||
pnode = g_slice_new(proto_tree);
|
||||
PROTO_NODE_INIT(pnode);
|
||||
|
@ -4111,8 +4088,6 @@ proto_tree_create_root(packet_info *pinfo)
|
|||
/* Make sure we can access pinfo everywhere */
|
||||
pnode->tree_data->pinfo = pinfo;
|
||||
|
||||
pnode->tree_data->mem_pool = pool;
|
||||
|
||||
/* Don't initialize the tree_data_t. Wait until we know we need it */
|
||||
pnode->tree_data->interesting_hfids = NULL;
|
||||
|
||||
|
|
|
@ -486,7 +486,6 @@ typedef struct {
|
|||
gboolean fake_protocols;
|
||||
gint count;
|
||||
struct _packet_info *pinfo;
|
||||
wmem_allocator_t *mem_pool;
|
||||
} tree_data_t;
|
||||
|
||||
/** Each proto_tree, proto_item is one of these. */
|
||||
|
@ -611,7 +610,7 @@ WS_DLL_PUBLIC void proto_tree_children_foreach(proto_tree *tree,
|
|||
#define PTREE_DATA(proto_tree) ((proto_tree)->tree_data)
|
||||
|
||||
/** Retrieve the wmem_allocator_t from a proto_node */
|
||||
#define PNODE_POOL(proto_node) ((proto_node)->tree_data->mem_pool)
|
||||
#define PNODE_POOL(proto_node) ((proto_node)->tree_data->pinfo->pool)
|
||||
|
||||
/** Sets up memory used by proto routines. Called at program startup */
|
||||
void proto_init(void (register_all_protocols_func)(register_cb cb, gpointer client_data),
|
||||
|
|
Loading…
Reference in New Issue