forked from osmocom/wireshark
Reintroduce back epan_dissect_reset(), proto_tree_reset()
This time it makes more sense, cause for each dissection we need two wmem allocators. Reseting wmem allocator is much faster than destroy & create. svn path=/trunk/; revision=52706
This commit is contained in:
parent
107e4a6c80
commit
bad81b517f
35
epan/epan.c
35
epan/epan.c
|
@ -235,6 +235,35 @@ epan_dissect_init(epan_dissect_t *edt, epan_t *session, const gboolean create_pr
|
||||||
return edt;
|
return edt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
epan_dissect_reset(epan_dissect_t *edt)
|
||||||
|
{
|
||||||
|
/* We have to preserve the pool pointer across the memzeroing */
|
||||||
|
wmem_allocator_t *tmp;
|
||||||
|
|
||||||
|
g_assert(edt);
|
||||||
|
|
||||||
|
g_slist_free(edt->pi.dependent_frames);
|
||||||
|
|
||||||
|
/* Free the data sources list. */
|
||||||
|
free_data_sources(&edt->pi);
|
||||||
|
|
||||||
|
if (edt->tvb) {
|
||||||
|
/* Free all tvb's chained from this tvb */
|
||||||
|
tvb_free_chain(edt->tvb);
|
||||||
|
edt->tvb = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (edt->tree)
|
||||||
|
proto_tree_reset(edt->tree);
|
||||||
|
|
||||||
|
tmp = edt->pi.pool;
|
||||||
|
wmem_free_all(tmp);
|
||||||
|
|
||||||
|
memset(&edt->pi, 0, sizeof(edt->pi));
|
||||||
|
edt->pi.pool = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
epan_dissect_t*
|
epan_dissect_t*
|
||||||
epan_dissect_new(epan_t *session, const gboolean create_proto_tree, const gboolean proto_tree_visible)
|
epan_dissect_new(epan_t *session, const gboolean create_proto_tree, const gboolean proto_tree_visible)
|
||||||
{
|
{
|
||||||
|
@ -291,8 +320,10 @@ epan_dissect_cleanup(epan_dissect_t* edt)
|
||||||
/* Free the data sources list. */
|
/* Free the data sources list. */
|
||||||
free_data_sources(&edt->pi);
|
free_data_sources(&edt->pi);
|
||||||
|
|
||||||
/* Free all tvb's chained from this tvb */
|
if (edt->tvb) {
|
||||||
tvb_free_chain(edt->tvb);
|
/* Free all tvb's chained from this tvb */
|
||||||
|
tvb_free_chain(edt->tvb);
|
||||||
|
}
|
||||||
|
|
||||||
if (edt->tree) {
|
if (edt->tree) {
|
||||||
proto_tree_free(edt->tree);
|
proto_tree_free(edt->tree);
|
||||||
|
|
|
@ -152,6 +152,10 @@ WS_DLL_PUBLIC
|
||||||
epan_dissect_t*
|
epan_dissect_t*
|
||||||
epan_dissect_new(epan_t *session, const gboolean create_proto_tree, const gboolean proto_tree_visible);
|
epan_dissect_new(epan_t *session, const gboolean create_proto_tree, const gboolean proto_tree_visible);
|
||||||
|
|
||||||
|
WS_DLL_PUBLIC
|
||||||
|
void
|
||||||
|
epan_dissect_reset(epan_dissect_t *edt);
|
||||||
|
|
||||||
/** Indicate whether we should fake protocols or not */
|
/** Indicate whether we should fake protocols or not */
|
||||||
WS_DLL_PUBLIC
|
WS_DLL_PUBLIC
|
||||||
void
|
void
|
||||||
|
|
35
epan/proto.c
35
epan/proto.c
|
@ -551,6 +551,33 @@ proto_tree_free_node(proto_node *node, gpointer data _U_)
|
||||||
FVALUE_CLEANUP(&finfo->value);
|
FVALUE_CLEANUP(&finfo->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
proto_tree_reset(proto_tree *tree)
|
||||||
|
{
|
||||||
|
tree_data_t *tree_data = PTREE_DATA(tree);
|
||||||
|
|
||||||
|
proto_tree_children_foreach(tree, proto_tree_free_node, NULL);
|
||||||
|
|
||||||
|
/* free tree data */
|
||||||
|
if (tree_data->interesting_hfids) {
|
||||||
|
/* Free all the GPtrArray's in the interesting_hfids hash. */
|
||||||
|
g_hash_table_foreach(tree_data->interesting_hfids,
|
||||||
|
free_GPtrArray_value, NULL);
|
||||||
|
|
||||||
|
/* And then destroy the hash. */
|
||||||
|
g_hash_table_destroy(tree_data->interesting_hfids);
|
||||||
|
|
||||||
|
tree_data->interesting_hfids = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Reset track of the number of children */
|
||||||
|
tree_data->count = 0;
|
||||||
|
|
||||||
|
wmem_free_all(tree_data->mem_pool);
|
||||||
|
|
||||||
|
PROTO_NODE_INIT(tree);
|
||||||
|
}
|
||||||
|
|
||||||
/* frees the resources that the dissection a proto_tree uses */
|
/* frees the resources that the dissection a proto_tree uses */
|
||||||
void
|
void
|
||||||
proto_tree_free(proto_tree *tree)
|
proto_tree_free(proto_tree *tree)
|
||||||
|
@ -578,6 +605,10 @@ proto_tree_free(proto_tree *tree)
|
||||||
wmem_free_all(pool);
|
wmem_free_all(pool);
|
||||||
tree_pool_cache = pool;
|
tree_pool_cache = pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_slice_free(tree_data_t, tree_data);
|
||||||
|
|
||||||
|
g_slice_free(proto_tree, tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Is the parsing being done for a visible proto_tree or an invisible one?
|
/* Is the parsing being done for a visible proto_tree or an invisible one?
|
||||||
|
@ -4086,11 +4117,11 @@ proto_tree_create_root(packet_info *pinfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the proto_node */
|
/* Initialize the proto_node */
|
||||||
pnode = wmem_new(pool, proto_node);
|
pnode = g_slice_new(proto_tree);
|
||||||
PROTO_NODE_INIT(pnode);
|
PROTO_NODE_INIT(pnode);
|
||||||
pnode->parent = NULL;
|
pnode->parent = NULL;
|
||||||
PNODE_FINFO(pnode) = NULL;
|
PNODE_FINFO(pnode) = NULL;
|
||||||
pnode->tree_data = wmem_new(pool, tree_data_t);
|
pnode->tree_data = g_slice_new(tree_data_t);
|
||||||
|
|
||||||
/* Make sure we can access pinfo everywhere */
|
/* Make sure we can access pinfo everywhere */
|
||||||
pnode->tree_data->pinfo = pinfo;
|
pnode->tree_data->pinfo = pinfo;
|
||||||
|
|
|
@ -709,6 +709,8 @@ WS_DLL_PUBLIC int proto_item_get_len(const proto_item *ti);
|
||||||
@return the new tree root */
|
@return the new tree root */
|
||||||
extern proto_tree* proto_tree_create_root(struct _packet_info *pinfo);
|
extern proto_tree* proto_tree_create_root(struct _packet_info *pinfo);
|
||||||
|
|
||||||
|
void proto_tree_reset(proto_tree *tree);
|
||||||
|
|
||||||
/** Clear memory for entry proto_tree. Clears proto_tree struct also.
|
/** Clear memory for entry proto_tree. Clears proto_tree struct also.
|
||||||
@param tree the tree to free */
|
@param tree the tree to free */
|
||||||
WS_DLL_PUBLIC void proto_tree_free(proto_tree *tree);
|
WS_DLL_PUBLIC void proto_tree_free(proto_tree *tree);
|
||||||
|
|
Loading…
Reference in New Issue