forked from osmocom/wireshark
Some more random removal of ep_ memory.
Change-Id: I6eccd20280e907bd9e6a5fcf873ccf80afddecac Reviewed-on: https://code.wireshark.org/review/6416 Petri-Dish: Hadriel Kaplan <hadrielk@yahoo.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
45cbdbc70a
commit
d296c75247
|
@ -312,16 +312,16 @@ information).
|
|||
|
||||
Byte Array Accessors:
|
||||
|
||||
gchar *tvb_bytes_to_str(tvbuff_t *tvb, gint offset, gint len);
|
||||
gchar *tvb_bytes_to_str(wmem_allocator_t *scope, tvbuff_t *tvb, gint offset, gint len);
|
||||
|
||||
Formats a bunch of data from a tvbuff as bytes, returning a pointer
|
||||
to the string with the data formatted as two hex digits for each byte.
|
||||
The string pointed to is stored in an "ep_alloc'd" buffer which will be freed
|
||||
before the next frame is dissected. The formatted string will contain the hex digits
|
||||
for at most the first 16 bytes of the data. If len is greater than 16 bytes, a
|
||||
trailing "..." will be added to the string.
|
||||
The string pointed to is stored in an "wmem_alloc'd" buffer which will be freed
|
||||
depending on its scope (typically wmem_packet_scope which is freed after the frame).
|
||||
The formatted string will contain the hex digits for at most the first 16 bytes of
|
||||
the data. If len is greater than 16 bytes, a trailing "..." will be added to the string.
|
||||
|
||||
gchar *tvb_bytes_to_str_punct(tvbuff_t *tvb, gint offset, gint len, gchar punct);
|
||||
gchar *tvb_bytes_to_str_punct(wmem_allocator_t *scope, tvbuff_t *tvb, gint offset, gint len, gchar punct);
|
||||
|
||||
This function is similar to tvb_bytes_to_str(...) except that 'punct' is inserted
|
||||
between the hex representation of each byte.
|
||||
|
|
|
@ -197,7 +197,7 @@ tap_queue_packet() is using its own instance of private struct variable
|
|||
so they don't overwrite each other.
|
||||
|
||||
See packet-ip.c which has a simple solution to the problem. It creates
|
||||
a unique instance of the IP header using ep_alloc().
|
||||
a unique instance of the IP header using wmem_alloc().
|
||||
Previous versions used a static struct of 4 instances of the IP header
|
||||
struct and cycled through them each time the dissector was called. (4
|
||||
was just a number taken out of the blue but it should be enough for most
|
||||
|
|
|
@ -1017,7 +1017,7 @@ of the dissector.
|
|||
void dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
||||
{
|
||||
...
|
||||
fooinfo = ep_alloc(sizeof(struct FooTap));
|
||||
fooinfo = wmem_alloc(wmem_packet_scope(), sizeof(struct FooTap));
|
||||
fooinfo->packet_type = tvb_get_guint8(tvb, 0);
|
||||
fooinfo->priority = tvb_get_ntohs(tvb, 8);
|
||||
...
|
||||
|
|
|
@ -636,10 +636,10 @@ eui64_repr_len(fvalue_t *fv _U_, ftrepr_t rtype _U_, int field_display _U_)
|
|||
static void
|
||||
eui64_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, int field_display _U_, char *buf)
|
||||
{
|
||||
guint8 *p_eui64 = (guint8 *)ep_alloc(8);
|
||||
guint8 *p_eui64 = (guint8 *)ep_alloc(8);
|
||||
|
||||
/* Copy and convert the address to network byte order. */
|
||||
*(guint64 *)(void *)(p_eui64) = pntoh64(&(fv->value.integer64));
|
||||
/* Copy and convert the address to network byte order. */
|
||||
*(guint64 *)(void *)(p_eui64) = pntoh64(&(fv->value.integer64));
|
||||
|
||||
g_snprintf(buf, EUI64_STR_LEN, "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
|
||||
p_eui64[0], p_eui64[1], p_eui64[2], p_eui64[3],
|
||||
|
|
|
@ -51,8 +51,8 @@ ResolveWin32UUID(e_guid_t if_id, char *uuid_name, int uuid_name_max_len)
|
|||
DWORD uuid_max_size = MAX_PATH;
|
||||
TCHAR *reg_uuid_str;
|
||||
|
||||
reg_uuid_name=ep_alloc(MAX_PATH*sizeof(TCHAR));
|
||||
reg_uuid_str=ep_alloc(MAX_PATH*sizeof(TCHAR));
|
||||
reg_uuid_name=wmem_alloc(wmem_packet_scope(), MAX_PATH*sizeof(TCHAR));
|
||||
reg_uuid_str=wmem_alloc(wmem_packet_scope(), MAX_PATH*sizeof(TCHAR));
|
||||
|
||||
if(uuid_name_max_len < 2){
|
||||
return 0;
|
||||
|
@ -159,7 +159,7 @@ guids_get_guid_name(const e_guid_t *guid)
|
|||
#ifdef _WIN32
|
||||
/* try to resolve the mapping from the Windows registry */
|
||||
/* XXX - prefill the resolving database with all the Windows registry entries once at init only (instead of searching each time)? */
|
||||
uuid_name=ep_alloc(128);
|
||||
uuid_name=wmem_alloc(wmem_packet_scope(), 128);
|
||||
if(ResolveWin32UUID(*guid, uuid_name, 128)) {
|
||||
return uuid_name;
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ guids_resolve_guid_to_str(const e_guid_t *guid)
|
|||
return name;
|
||||
}
|
||||
|
||||
return ep_strdup_printf("%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||
return wmem_strdup_printf(wmem_packet_scope(), "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||
guid->data1, guid->data2, guid->data3,
|
||||
guid->data4[0], guid->data4[1],
|
||||
guid->data4[2], guid->data4[3],
|
||||
|
|
|
@ -908,7 +908,7 @@ ptvcursor_new_subtree_levels(ptvcursor_t *ptvc)
|
|||
DISSECTOR_ASSERT(ptvc->pushed_tree_max <= SUBTREE_MAX_LEVELS-SUBTREE_ONCE_ALLOCATION_NUMBER);
|
||||
ptvc->pushed_tree_max += SUBTREE_ONCE_ALLOCATION_NUMBER;
|
||||
|
||||
pushed_tree = (subtree_lvl *)ep_alloc(sizeof(subtree_lvl) * ptvc->pushed_tree_max);
|
||||
pushed_tree = (subtree_lvl *)wmem_alloc(wmem_packet_scope(), sizeof(subtree_lvl) * ptvc->pushed_tree_max);
|
||||
DISSECTOR_ASSERT(pushed_tree != NULL);
|
||||
if (ptvc->pushed_tree)
|
||||
memcpy(pushed_tree, ptvc->pushed_tree, ptvc->pushed_tree_max - SUBTREE_ONCE_ALLOCATION_NUMBER);
|
||||
|
@ -931,7 +931,7 @@ ptvcursor_new(proto_tree *tree, tvbuff_t *tvb, gint offset)
|
|||
{
|
||||
ptvcursor_t *ptvc;
|
||||
|
||||
ptvc = (ptvcursor_t *)ep_alloc(sizeof(ptvcursor_t));
|
||||
ptvc = (ptvcursor_t *)wmem_alloc(wmem_packet_scope(), sizeof(ptvcursor_t));
|
||||
ptvc->tree = tree;
|
||||
ptvc->tvb = tvb;
|
||||
ptvc->offset = offset;
|
||||
|
@ -8027,7 +8027,7 @@ proto_tree_add_split_bits_item_ret_val(proto_tree *tree, const int hfindex, tvbu
|
|||
guint mask_greatest_bit_offset;
|
||||
guint octet_length;
|
||||
guint8 i;
|
||||
char *bf_str;
|
||||
char bf_str[256];
|
||||
char lbl_str[ITEM_LABEL_LENGTH];
|
||||
guint64 value;
|
||||
guint64 composite_bitmask;
|
||||
|
@ -8109,7 +8109,6 @@ proto_tree_add_split_bits_item_ret_val(proto_tree *tree, const int hfindex, tvbu
|
|||
TRY_TO_FAKE_THIS_ITEM(tree, hfindex, hf_field);
|
||||
|
||||
/* initialise the format string */
|
||||
bf_str = (char *)ep_alloc(256);
|
||||
bf_str[0] = '\0';
|
||||
|
||||
octet_offset = bit_offset >> 3;
|
||||
|
|
|
@ -103,7 +103,7 @@ typedef struct _protocol protocol_t;
|
|||
* the Info column and the protocol tree.
|
||||
*
|
||||
* If that string is dynamically allocated, it should be allocated with
|
||||
* ep_alloc(); using ep_strdup_printf() would work.
|
||||
* wmem_alloc() with wmem_packet_scope(); using wmem_strdup_printf() would work.
|
||||
*
|
||||
* If the WIRESHARK_ABORT_ON_DISSECTOR_BUG environment variable is set,
|
||||
* it will call abort(), instead, to make it easier to get a stack trace.
|
||||
|
|
Loading…
Reference in New Issue