forked from osmocom/wireshark
Create a wmem pool in pinfo and use it for some address allocations.
A (better?) fix for https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8030 See also thread starting at: http://www.wireshark.org/lists/wireshark-dev/201212/msg00001.html svn path=/trunk/; revision=46331
This commit is contained in:
parent
2461373edd
commit
b9c6f71fe4
|
@ -33,6 +33,7 @@
|
|||
|
||||
#include <epan/packet.h>
|
||||
#include <epan/prefs.h>
|
||||
#include <epan/wmem/wmem.h>
|
||||
|
||||
#include "packet-bluetooth-hci.h"
|
||||
#include "packet-bthci_acl.h"
|
||||
|
@ -187,7 +188,7 @@ dissect_bthci_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|||
|
||||
remote_ether_addr = get_ether_name(remote_bdaddr->bd_addr);
|
||||
remote_length = (gint)(strlen(remote_ether_addr) + 3 + strlen(remote_name) + 1);
|
||||
remote_addr_name = se_alloc(remote_length);
|
||||
remote_addr_name = wmem_alloc(pinfo->pool, remote_length);
|
||||
|
||||
g_snprintf(remote_addr_name, remote_length, "%s (%s)", remote_ether_addr, remote_name);
|
||||
|
||||
|
@ -238,7 +239,7 @@ dissect_bthci_acl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|||
localhost_name = "";
|
||||
|
||||
localhost_length = (gint)(strlen(localhost_ether_addr) + 3 + strlen(localhost_name) + 1);
|
||||
localhost_addr_name = se_alloc(localhost_length);
|
||||
localhost_addr_name = wmem_alloc(pinfo->pool, localhost_length);
|
||||
|
||||
g_snprintf(localhost_addr_name, localhost_length, "%s (%s)", localhost_ether_addr, localhost_name);
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "oids.h"
|
||||
#include "emem.h"
|
||||
#include "wmem/wmem.h"
|
||||
#include "wmem/wmem_allocator_glib.h"
|
||||
#include "expert.h"
|
||||
|
||||
#ifdef HAVE_LUA
|
||||
|
@ -161,6 +162,8 @@ epan_dissect_init(epan_dissect_t *edt, const gboolean create_proto_tree, const g
|
|||
{
|
||||
g_assert(edt);
|
||||
|
||||
edt->pi.pool = wmem_create_glib_allocator();
|
||||
|
||||
if (create_proto_tree) {
|
||||
edt->tree = proto_tree_create_root(&edt->pi);
|
||||
proto_tree_set_visible(edt->tree, proto_tree_visible);
|
||||
|
@ -233,12 +236,15 @@ epan_dissect_cleanup(epan_dissect_t* edt)
|
|||
if (edt->tree) {
|
||||
proto_tree_free(edt->tree);
|
||||
}
|
||||
|
||||
wmem_free_all(edt->pi.pool);
|
||||
}
|
||||
|
||||
void
|
||||
epan_dissect_free(epan_dissect_t* edt)
|
||||
{
|
||||
epan_dissect_cleanup(edt);
|
||||
wmem_destroy_allocator(edt->pi.pool);
|
||||
g_free(edt);
|
||||
}
|
||||
|
||||
|
|
|
@ -319,9 +319,13 @@ void
|
|||
dissect_packet(epan_dissect_t *edt, struct wtap_pkthdr *phdr,
|
||||
const guchar *pd, frame_data *fd, column_info *cinfo)
|
||||
{
|
||||
/* We have to preserve the pool pointer across the memzeroing */
|
||||
wmem_allocator_t *tmp = edt->pi.pool;
|
||||
|
||||
if (cinfo != NULL)
|
||||
col_init(cinfo);
|
||||
memset(&edt->pi, 0, sizeof(edt->pi));
|
||||
edt->pi.pool = tmp;
|
||||
edt->pi.current_proto = "<Missing Protocol Name>";
|
||||
edt->pi.cinfo = cinfo;
|
||||
edt->pi.fd = fd;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "frame_data.h"
|
||||
#include "tvbuff.h"
|
||||
#include "address.h"
|
||||
#include "wmem/wmem.h"
|
||||
|
||||
/* Also defined in wiretap/wtap.h */
|
||||
#define P2P_DIR_UNKNOWN -1
|
||||
|
@ -212,6 +213,8 @@ typedef struct _packet_info {
|
|||
GSList* dependent_frames; /**< A list of frames which this one depends on */
|
||||
|
||||
GSList *frame_end_routines;
|
||||
|
||||
wmem_allocator_t *pool; /**< Memory pool scoped to the pinfo struct */
|
||||
} packet_info;
|
||||
|
||||
/**< For old code that hasn't yet been changed. */
|
||||
|
|
Loading…
Reference in New Issue