aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
Diffstat (limited to 'epan')
-rw-r--r--epan/color_filters.c4
-rw-r--r--epan/column.c8
-rw-r--r--epan/conversation_filter.c2
-rw-r--r--epan/crypt/dot11decrypt.c8
-rw-r--r--epan/disabled_protos.c4
-rw-r--r--epan/dissectors/packet-batadv.c68
-rw-r--r--epan/dissectors/packet-btmesh.c4
-rw-r--r--epan/dissectors/packet-dbus.c12
-rw-r--r--epan/dissectors/packet-dcerpc.c32
-rw-r--r--epan/dissectors/packet-dpaux.c3
-rw-r--r--epan/dissectors/packet-exported_pdu.c4
-rw-r--r--epan/dissectors/packet-fpp.c2
-rw-r--r--epan/dissectors/packet-giop.c8
-rw-r--r--epan/dissectors/packet-hpfeeds.c2
-rw-r--r--epan/dissectors/packet-idn.c4
-rw-r--r--epan/dissectors/packet-ieee802a.c2
-rw-r--r--epan/dissectors/packet-imf.c6
-rw-r--r--epan/dissectors/packet-infiniband.c4
-rw-r--r--epan/dissectors/packet-ipmi.c2
-rw-r--r--epan/dissectors/packet-ipsec.c2
-rw-r--r--epan/dissectors/packet-k12.c2
-rw-r--r--epan/dissectors/packet-mac-lte-framed.c2
-rw-r--r--epan/dissectors/packet-mswsp.c2
-rw-r--r--epan/dissectors/packet-mtp3.c4
-rw-r--r--epan/dissectors/packet-nano.c6
-rw-r--r--epan/dissectors/packet-nvme-tcp.c3
-rw-r--r--epan/dissectors/packet-radius.c8
-rw-r--r--epan/dissectors/packet-rpc.c2
-rw-r--r--epan/dissectors/packet-sctp.c10
-rw-r--r--epan/dissectors/packet-smb.c4
-rw-r--r--epan/dissectors/packet-smtp.c4
-rw-r--r--epan/dissectors/packet-snort-config.c4
-rw-r--r--epan/dissectors/packet-snort.c2
-rw-r--r--epan/dissectors/packet-soupbintcp.c6
-rw-r--r--epan/dissectors/packet-ssh.c2
-rw-r--r--epan/dissectors/packet-tpncp.c3
-rw-r--r--epan/dissectors/packet-twamp.c2
-rw-r--r--epan/dissectors/packet-umts_rlc.c12
-rw-r--r--epan/dissectors/packet-zvt.c3
-rw-r--r--epan/funnel.c4
-rw-r--r--epan/packet.c12
-rw-r--r--epan/plugin_if.c6
-rw-r--r--epan/prefs.c4
-rw-r--r--epan/print_stream.c4
-rw-r--r--epan/proto_data.c2
-rw-r--r--epan/srt_table.c2
-rw-r--r--epan/stat_tap_ui.c2
-rw-r--r--epan/stats_tree.c20
-rw-r--r--epan/tap.c4
-rw-r--r--epan/tvbparse.c4
-rw-r--r--epan/uat.c4
-rw-r--r--epan/wslua/init_wslua.c2
-rw-r--r--epan/wslua/wslua_file_common.c4
-rw-r--r--epan/wslua/wslua_file_handler.c2
-rw-r--r--epan/wslua/wslua_gui.c14
-rw-r--r--epan/wslua/wslua_pref.c2
-rw-r--r--epan/wslua/wslua_proto.c2
-rw-r--r--epan/wslua/wslua_proto_field.c4
-rw-r--r--epan/wslua/wslua_tree.c4
-rw-r--r--epan/wslua/wslua_util.c2
60 files changed, 174 insertions, 192 deletions
diff --git a/epan/color_filters.c b/epan/color_filters.c
index 8dfd8c2e32..08cf3da4f0 100644
--- a/epan/color_filters.c
+++ b/epan/color_filters.c
@@ -61,7 +61,7 @@ color_filter_new(const gchar *name, /* The name of the filter to create
{
color_filter_t *colorf;
- colorf = (color_filter_t *)g_malloc0(sizeof (color_filter_t));
+ colorf = g_new0(color_filter_t, 1);
colorf->filter_name = g_strdup(name);
colorf->filter_text = g_strdup(filter_string);
colorf->bg_color = *bg_color;
@@ -261,7 +261,7 @@ color_filter_clone(color_filter_t *colorf)
{
color_filter_t *new_colorf;
- new_colorf = (color_filter_t *)g_malloc(sizeof (color_filter_t));
+ new_colorf = g_new(color_filter_t, 1);
new_colorf->filter_name = g_strdup(colorf->filter_name);
new_colorf->filter_text = g_strdup(colorf->filter_text);
new_colorf->bg_color = colorf->bg_color;
diff --git a/epan/column.c b/epan/column.c
index 81f71b51cc..922f03daea 100644
--- a/epan/column.c
+++ b/epan/column.c
@@ -846,17 +846,17 @@ col_finalize(column_info *cinfo)
col_item->col_custom_dfilter = NULL;
}
- col_item->fmt_matx = (gboolean *) g_malloc0(sizeof(gboolean) * NUM_COL_FMTS);
+ col_item->fmt_matx = g_new0(gboolean, NUM_COL_FMTS);
get_column_format_matches(col_item->fmt_matx, col_item->col_fmt);
col_item->col_data = NULL;
if (col_item->col_fmt == COL_INFO)
- col_item->col_buf = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_INFO_LEN);
+ col_item->col_buf = g_new(gchar, COL_MAX_INFO_LEN);
else
- col_item->col_buf = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
+ col_item->col_buf = g_new(gchar, COL_MAX_LEN);
cinfo->col_expr.col_expr[i] = "";
- cinfo->col_expr.col_expr_val[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
+ cinfo->col_expr.col_expr_val[i] = g_new(gchar, COL_MAX_LEN);
}
cinfo->col_expr.col_expr[i] = NULL;
diff --git a/epan/conversation_filter.c b/epan/conversation_filter.c
index 982b93d823..4379c70daa 100644
--- a/epan/conversation_filter.c
+++ b/epan/conversation_filter.c
@@ -24,7 +24,7 @@ void register_conversation_filter(const char *proto_name, const char *display_na
is_filter_valid_func is_filter_valid, build_filter_string_func build_filter_string) {
conversation_filter_t *entry;
- entry = (conversation_filter_t *)g_malloc(sizeof(conversation_filter_t));
+ entry = g_new(conversation_filter_t, 1);
entry->proto_name = proto_name;
entry->display_name = display_name;
diff --git a/epan/crypt/dot11decrypt.c b/epan/crypt/dot11decrypt.c
index ee66810845..eda65ade5e 100644
--- a/epan/crypt/dot11decrypt.c
+++ b/epan/crypt/dot11decrypt.c
@@ -2487,7 +2487,7 @@ parse_key_string(gchar* input_string, guint8 key_type)
if (res && key_ba->len > 0) {
/* Key is correct! It was probably an 'old style' WEP key */
/* Create the decryption_key_t structure, fill it and return it*/
- dk = (decryption_key_t *)g_malloc(sizeof(decryption_key_t));
+ dk = g_new(decryption_key_t, 1);
dk->type = DOT11DECRYPT_KEY_TYPE_WEP;
/* XXX - The current key handling code in the GUI requires
@@ -2579,7 +2579,7 @@ parse_key_string(gchar* input_string, guint8 key_type)
}
/* Key was correct!!! Create the new decryption_key_t ... */
- dk = (decryption_key_t*)g_malloc(sizeof(decryption_key_t));
+ dk = g_new(decryption_key_t, 1);
dk->type = DOT11DECRYPT_KEY_TYPE_WPA_PWD;
dk->key = g_string_new(key);
@@ -2613,7 +2613,7 @@ parse_key_string(gchar* input_string, guint8 key_type)
}
/* Key was correct!!! Create the new decryption_key_t ... */
- dk = (decryption_key_t*)g_malloc(sizeof(decryption_key_t));
+ dk = g_new(decryption_key_t, 1);
dk->type = DOT11DECRYPT_KEY_TYPE_WPA_PSK;
dk->key = g_string_new(input_string);
@@ -2647,7 +2647,7 @@ parse_key_string(gchar* input_string, guint8 key_type)
g_byte_array_free(key_ba, TRUE);
return NULL;
}
- dk = (decryption_key_t*)g_malloc(sizeof(decryption_key_t));
+ dk = g_new(decryption_key_t, 1);
dk->type = DOT11DECRYPT_KEY_TYPE_TK;
dk->key = g_string_new(input_string);
dk->bits = (guint) dk->key->len * 4;
diff --git a/epan/disabled_protos.c b/epan/disabled_protos.c
index d7e715fe4f..a558aaf48d 100644
--- a/epan/disabled_protos.c
+++ b/epan/disabled_protos.c
@@ -355,7 +355,7 @@ read_protos_list_file(const char *ff_path, FILE *ff, GList **flp)
prot_name[prot_name_index] = '\0';
/* Add the new protocol to the list of disabled protocols */
- prot = (protocol_def *) g_malloc(sizeof(protocol_def));
+ prot = g_new(protocol_def, 1);
prot->name = g_strdup(prot_name);
*flp = g_list_append(*flp, prot);
}
@@ -671,7 +671,7 @@ read_heur_dissector_list_file(const char *ff_path, FILE *ff, GList **flp)
heuristic_name[name_index] = '\0';
/* Add the new protocol to the list of protocols */
- heur = (heur_protocol_def *) g_malloc(sizeof(heur_protocol_def));
+ heur = g_new(heur_protocol_def, 1);
heur->name = g_strdup(heuristic_name);
heur->enabled = enabled;
*flp = g_list_append(*flp, heur);
diff --git a/epan/dissectors/packet-batadv.c b/epan/dissectors/packet-batadv.c
index 01483fda20..a1c4bea020 100644
--- a/epan/dissectors/packet-batadv.c
+++ b/epan/dissectors/packet-batadv.c
@@ -1121,7 +1121,7 @@ static int dissect_batadv_batman_v5(tvbuff_t *tvb, int offset, packet_info *pinf
tvbuff_t *next_tvb;
- batman_packeth = (struct batman_packet_v5 *)wmem_alloc(wmem_packet_scope(), sizeof(struct batman_packet_v5));
+ batman_packeth = wmem_new(wmem_packet_scope(), struct batman_packet_v5);
type = tvb_get_guint8(tvb, offset+0);
batman_packeth->version = tvb_get_guint8(tvb, offset+1);
@@ -1216,7 +1216,7 @@ static int dissect_batadv_batman_v7(tvbuff_t *tvb, int offset, packet_info *pinf
tvbuff_t *next_tvb;
- batman_packeth = (struct batman_packet_v7 *)wmem_alloc(wmem_packet_scope(), sizeof(struct batman_packet_v7));
+ batman_packeth = wmem_new(wmem_packet_scope(), struct batman_packet_v7);
type = tvb_get_guint8(tvb, offset+0);
batman_packeth->version = tvb_get_guint8(tvb, offset+1);
@@ -1301,7 +1301,7 @@ static int dissect_batadv_batman_v9(tvbuff_t *tvb, int offset, packet_info *pinf
tvbuff_t *next_tvb;
- batman_packeth = (struct batman_packet_v9 *)wmem_alloc(wmem_packet_scope(), sizeof(struct batman_packet_v9));
+ batman_packeth = wmem_new(wmem_packet_scope(), struct batman_packet_v9);
type = tvb_get_guint8(tvb, offset+0);
batman_packeth->version = tvb_get_guint8(tvb, offset+1);
@@ -1394,7 +1394,7 @@ static int dissect_batadv_batman_v10(tvbuff_t *tvb, int offset, packet_info *pin
tvbuff_t *next_tvb;
- batman_packeth = (struct batman_packet_v10 *)wmem_alloc(wmem_packet_scope(), sizeof(struct batman_packet_v10));
+ batman_packeth = wmem_new(wmem_packet_scope(), struct batman_packet_v10);
type = tvb_get_guint8(tvb, offset+0);
batman_packeth->version = tvb_get_guint8(tvb, offset+1);
@@ -1487,7 +1487,7 @@ static int dissect_batadv_batman_v11(tvbuff_t *tvb, int offset, packet_info *pin
tvbuff_t *next_tvb;
- batman_packeth = (struct batman_packet_v11 *)wmem_alloc(wmem_packet_scope(), sizeof(struct batman_packet_v11));
+ batman_packeth = wmem_new(wmem_packet_scope(), struct batman_packet_v11);
type = tvb_get_guint8(tvb, offset+0);
batman_packeth->version = tvb_get_guint8(tvb, offset+1);
@@ -1573,7 +1573,7 @@ static int dissect_batadv_batman_v14(tvbuff_t *tvb, int offset, packet_info *pin
tvbuff_t *next_tvb;
gint length_remaining;
- batman_packeth = (struct batman_packet_v14 *)wmem_alloc(wmem_packet_scope(), sizeof(struct batman_packet_v14));
+ batman_packeth = wmem_new(wmem_packet_scope(), struct batman_packet_v14);
type = tvb_get_guint8(tvb, offset+0);
batman_packeth->version = tvb_get_guint8(tvb, offset+1);
@@ -1712,8 +1712,7 @@ static int dissect_batadv_iv_ogm_v15(tvbuff_t *tvb, int offset,
if (version == 0 || type != BATADV_IV_OGM_V15)
return -1;
- iv_ogm_packeth = (struct iv_ogm_packet_v15 *)wmem_alloc(wmem_packet_scope(),
- sizeof(struct iv_ogm_packet_v15));
+ iv_ogm_packeth = wmem_new(wmem_packet_scope(), struct iv_ogm_packet_v15);
/* Set info column */
col_clear(pinfo->cinfo, COL_INFO);
@@ -1856,7 +1855,7 @@ static void dissect_batadv_bcast_v6(tvbuff_t *tvb, packet_info *pinfo, proto_tre
proto_tree *batadv_bcast_tree;
proto_item *ti;
- bcast_packeth = (struct bcast_packet_v6 *)wmem_alloc(wmem_packet_scope(), sizeof(struct bcast_packet_v6));
+ bcast_packeth = wmem_new(wmem_packet_scope(), struct bcast_packet_v6);
bcast_packeth->version = tvb_get_guint8(tvb, 1);
set_address_tvb(&bcast_packeth->orig, AT_ETHER, 6, tvb, 2);
@@ -1910,7 +1909,7 @@ static void dissect_batadv_bcast_v10(tvbuff_t *tvb, packet_info *pinfo, proto_tr
proto_tree *batadv_bcast_tree;
proto_item *ti;
- bcast_packeth = (struct bcast_packet_v10 *)wmem_alloc(wmem_packet_scope(), sizeof(struct bcast_packet_v10));
+ bcast_packeth = wmem_new(wmem_packet_scope(), struct bcast_packet_v10);
bcast_packeth->version = tvb_get_guint8(tvb, 1);
set_address_tvb(&bcast_packeth->orig, AT_ETHER, 6, tvb, 2);
@@ -1969,7 +1968,7 @@ static void dissect_batadv_bcast_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tr
proto_tree *batadv_bcast_tree;
proto_item *ti;
- bcast_packeth = (struct bcast_packet_v14 *)wmem_alloc(wmem_packet_scope(), sizeof(struct bcast_packet_v14));
+ bcast_packeth = wmem_new(wmem_packet_scope(), struct bcast_packet_v14);
bcast_packeth->packet_type = tvb_get_guint8(tvb, 0);
bcast_packeth->version = tvb_get_guint8(tvb, 1);
@@ -2069,7 +2068,7 @@ static void dissect_batadv_icmp_v6(tvbuff_t *tvb, packet_info *pinfo, proto_tree
proto_tree *batadv_icmp_tree;
proto_item *ti;
- icmp_packeth = (struct icmp_packet_v6 *)wmem_alloc(wmem_packet_scope(), sizeof(struct icmp_packet_v6));
+ icmp_packeth = wmem_new(wmem_packet_scope(), struct icmp_packet_v6);
icmp_packeth->version = tvb_get_guint8(tvb, 1);
icmp_packeth->msg_type = tvb_get_guint8(tvb, 2);
@@ -2192,7 +2191,7 @@ static void dissect_batadv_icmp_v7(tvbuff_t *tvb, packet_info *pinfo, proto_tree
gint length_remaining;
int offset = 0;
- icmp_packeth = (struct icmp_packet_v7 *)wmem_alloc(wmem_packet_scope(), sizeof(struct icmp_packet_v7));
+ icmp_packeth = wmem_new(wmem_packet_scope(), struct icmp_packet_v7);
icmp_packeth->version = tvb_get_guint8(tvb, 1);
icmp_packeth->msg_type = tvb_get_guint8(tvb, 2);
@@ -2272,7 +2271,7 @@ static void dissect_batadv_icmp_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tre
gint length_remaining;
int offset = 0;
- icmp_packeth = (struct icmp_packet_v14 *)wmem_alloc(wmem_packet_scope(), sizeof(struct icmp_packet_v14));
+ icmp_packeth = wmem_new(wmem_packet_scope(), struct icmp_packet_v14);
icmp_packeth->version = tvb_get_guint8(tvb, 1);
icmp_packeth->ttl = tvb_get_guint8(tvb, 2);
@@ -2358,8 +2357,7 @@ static void dissect_batadv_icmp_tp_v15(tvbuff_t *tvb, packet_info *pinfo,
guint32 msg_type;
int offset = 0;
- icmp_packeth = (struct icmp_tp_packet_v15 *)wmem_alloc(wmem_packet_scope(),
- sizeof(struct icmp_tp_packet_v15));
+ icmp_packeth = wmem_new(wmem_packet_scope(), struct icmp_tp_packet_v15);
/* Set info column */
col_clear(pinfo->cinfo, COL_INFO);
@@ -2462,8 +2460,7 @@ static void dissect_batadv_icmp_simple_v15(tvbuff_t *tvb, packet_info *pinfo,
int offset = 0;
guint32 seqno;
- icmp_packeth = (struct icmp_packet_v15 *)wmem_alloc(wmem_packet_scope(),
- sizeof(struct icmp_packet_v15));
+ icmp_packeth = wmem_new(wmem_packet_scope(), struct icmp_packet_v15);
/* Set info column */
col_clear(pinfo->cinfo, COL_INFO);
@@ -2607,7 +2604,7 @@ static void dissect_batadv_unicast_v6(tvbuff_t *tvb, packet_info *pinfo, proto_t
proto_tree *batadv_unicast_tree;
proto_item *ti;
- unicast_packeth = (struct unicast_packet_v6 *)wmem_alloc(wmem_packet_scope(), sizeof(struct unicast_packet_v6));
+ unicast_packeth = wmem_new(wmem_packet_scope(), struct unicast_packet_v6);
unicast_packeth->version = tvb_get_guint8(tvb, 1);
set_address_tvb(&unicast_packeth->dest, AT_ETHER, 6, tvb, 2);
@@ -2663,7 +2660,7 @@ static void dissect_batadv_unicast_v14(tvbuff_t *tvb, packet_info *pinfo, proto_
proto_tree *batadv_unicast_tree;
proto_item *ti;
- unicast_packeth = (struct unicast_packet_v14 *)wmem_alloc(wmem_packet_scope(), sizeof(struct unicast_packet_v14));
+ unicast_packeth = wmem_new(wmem_packet_scope(), struct unicast_packet_v14);
unicast_packeth->packet_type = tvb_get_guint8(tvb, 0);
unicast_packeth->version = tvb_get_guint8(tvb, 1);
@@ -2747,7 +2744,7 @@ static void dissect_batadv_unicast_4addr_v14(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *batadv_unicast_4addr_tree;
proto_item *ti;
- unicast_4addr_packeth = (struct unicast_4addr_packet_v14 *)wmem_alloc(wmem_packet_scope(), sizeof(struct unicast_4addr_packet_v14));
+ unicast_4addr_packeth = wmem_new(wmem_packet_scope(), struct unicast_4addr_packet_v14);
unicast_4addr_packeth->packet_type = tvb_get_guint8(tvb, 0);
unicast_4addr_packeth->version = tvb_get_guint8(tvb, 1);
@@ -2855,7 +2852,7 @@ static void dissect_batadv_unicast_frag_v12(tvbuff_t *tvb, packet_info *pinfo, p
int head = 0;
gint length_remaining;
- unicast_frag_packeth = (struct unicast_frag_packet_v12 *)wmem_alloc(wmem_packet_scope(), sizeof(struct unicast_frag_packet_v12));
+ unicast_frag_packeth = wmem_new(wmem_packet_scope(), struct unicast_frag_packet_v12);
unicast_frag_packeth->version = tvb_get_guint8(tvb, 1);
set_address_tvb(&unicast_frag_packeth->dest, AT_ETHER, 6, tvb, 2);
@@ -2944,7 +2941,7 @@ static void dissect_batadv_unicast_frag_v14(tvbuff_t *tvb, packet_info *pinfo, p
int head = 0;
gint length_remaining;
- unicast_frag_packeth = (struct unicast_frag_packet_v14 *)wmem_alloc(wmem_packet_scope(), sizeof(struct unicast_frag_packet_v14));
+ unicast_frag_packeth = wmem_new(wmem_packet_scope(), struct unicast_frag_packet_v14);
unicast_frag_packeth->version = tvb_get_guint8(tvb, 1);
unicast_frag_packeth->ttl = tvb_get_guint8(tvb, 2);
@@ -3042,8 +3039,7 @@ static void dissect_batadv_unicast_frag_v15(tvbuff_t *tvb, packet_info *pinfo,
int frag_no = 0;
gint length_remaining;
- unicast_frag_packeth = (struct unicast_frag_packet_v15 *)wmem_alloc(wmem_packet_scope(),
- sizeof(struct unicast_frag_packet_v15));
+ unicast_frag_packeth = wmem_new(wmem_packet_scope(), struct unicast_frag_packet_v15);
save_fragmented = pinfo->fragmented;
pinfo->fragmented = TRUE;
@@ -3191,7 +3187,7 @@ static void dissect_batadv_vis_v6(tvbuff_t *tvb, packet_info *pinfo, proto_tree
gint length_remaining;
int offset = 0, i;
- vis_packeth = (struct vis_packet_v6 *)wmem_alloc(wmem_packet_scope(), sizeof(struct vis_packet_v6));
+ vis_packeth = wmem_new(wmem_packet_scope(), struct vis_packet_v6);
vis_packeth->version = tvb_get_guint8(tvb, 1);
vis_packeth->vis_type = tvb_get_guint8(tvb, 2);
@@ -3307,7 +3303,7 @@ static void dissect_batadv_vis_v10(tvbuff_t *tvb, packet_info *pinfo, proto_tree
gint length_remaining;
int offset = 0, i;
- vis_packeth = (struct vis_packet_v10 *)wmem_alloc(wmem_packet_scope(), sizeof(struct vis_packet_v10));
+ vis_packeth = wmem_new(wmem_packet_scope(), struct vis_packet_v10);
vis_packeth->version = tvb_get_guint8(tvb, 1);
vis_packeth->vis_type = tvb_get_guint8(tvb, 2);
@@ -3399,7 +3395,7 @@ static void dissect_batadv_vis_v14(tvbuff_t *tvb, packet_info *pinfo, proto_tree
gint length_remaining;
int offset = 0, i;
- vis_packeth = (struct vis_packet_v14 *)wmem_alloc(wmem_packet_scope(), sizeof(struct vis_packet_v14));
+ vis_packeth = wmem_new(wmem_packet_scope(), struct vis_packet_v14);
vis_packeth->version = tvb_get_guint8(tvb, 1);
vis_packeth->ttl = tvb_get_guint8(tvb, 2);
@@ -3543,7 +3539,7 @@ static void dissect_batadv_tt_query_v14(tvbuff_t *tvb, packet_info *pinfo, proto
int offset = 0, i;
int tt_type;
- tt_query_packeth = (struct tt_query_packet_v14 *)wmem_alloc(wmem_packet_scope(), sizeof(struct tt_query_packet_v14));
+ tt_query_packeth = wmem_new(wmem_packet_scope(), struct tt_query_packet_v14);
tt_query_packeth->version = tvb_get_guint8(tvb, 1);
tt_query_packeth->ttl = tvb_get_guint8(tvb, 2);
@@ -3688,7 +3684,7 @@ static void dissect_batadv_roam_adv_v14(tvbuff_t *tvb, packet_info *pinfo, proto
gint length_remaining;
int offset = 0;
- roam_adv_packeth = (struct roam_adv_packet_v14 *)wmem_alloc(wmem_packet_scope(), sizeof(struct roam_adv_packet_v14));
+ roam_adv_packeth = wmem_new(wmem_packet_scope(), struct roam_adv_packet_v14);
roam_adv_packeth->version = tvb_get_guint8(tvb, 1);
roam_adv_packeth->ttl = tvb_get_guint8(tvb, 2);
@@ -3776,8 +3772,7 @@ static void dissect_batadv_coded_v15(tvbuff_t *tvb, packet_info *pinfo,
gint length_remaining;
int offset = 0;
- coded_packeth = (struct coded_packet_v15 *)wmem_alloc(wmem_packet_scope(),
- sizeof(struct coded_packet_v15));
+ coded_packeth = wmem_new(wmem_packet_scope(), struct coded_packet_v15);
/* Set tree info */
ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin,
@@ -3911,8 +3906,7 @@ static void dissect_batadv_elp_v15(tvbuff_t *tvb, packet_info *pinfo,
gint length_remaining;
int offset = 0;
- elp_packeth = (struct elp_packet_v15 *)wmem_alloc(wmem_packet_scope(),
- sizeof(struct elp_packet_v15));
+ elp_packeth = wmem_new(wmem_packet_scope(), struct elp_packet_v15);
/* Set tree info */
ti = proto_tree_add_protocol_format(tree, proto_batadv_plugin,
@@ -4009,8 +4003,7 @@ static int dissect_batadv_ogm2_v15(tvbuff_t *tvb, int offset,
if (version == 0 || type != BATADV_OGM2_V15)
return -1;
- ogm2_packeth = (struct ogm2_packet_v15 *)wmem_alloc(wmem_packet_scope(),
- sizeof(struct ogm2_packet_v15));
+ ogm2_packeth = wmem_new(wmem_packet_scope(), struct ogm2_packet_v15);
/* Set tree info */
ogm2_packeth->tvlv_len = tvb_get_ntohs(tvb, 16);
@@ -4120,8 +4113,7 @@ static void dissect_batadv_unicast_tvlv_v15(tvbuff_t *tvb, packet_info *pinfo,
proto_tree *batadv_unicast_tvlv_tree;
proto_item *ti;
- unicast_tvlv_packeth = (struct unicast_tvlv_packet_v15 *)wmem_alloc(wmem_packet_scope(),
- sizeof(struct unicast_tvlv_packet_v15));
+ unicast_tvlv_packeth = wmem_new(wmem_packet_scope(), struct unicast_tvlv_packet_v15);
/* Set info column */
col_clear(pinfo->cinfo, COL_INFO);
diff --git a/epan/dissectors/packet-btmesh.c b/epan/dissectors/packet-btmesh.c
index f1562a2ed3..124faf86f8 100644
--- a/epan/dissectors/packet-btmesh.c
+++ b/epan/dissectors/packet-btmesh.c
@@ -3630,10 +3630,10 @@ uat_btmesh_record_update_cb(void *r, char **err _U_)
g_free(rec->network_key);
rec->network_key_length = compute_ascii_key(&rec->network_key, rec->network_key_string);
g_free(rec->encryptionkey);
- rec->encryptionkey = (guint8 *)g_malloc(16 * sizeof(guint8));
+ rec->encryptionkey = g_new(guint8, 16);
memset(rec->encryptionkey, 0, 16 * sizeof(guint8));
g_free(rec->privacykey);
- rec->privacykey = (guint8 *)g_malloc(16 * sizeof(guint8));
+ rec->privacykey = g_new(guint8, 16);
if (create_master_security_keys(rec)) {
rec->valid++;
}
diff --git a/epan/dissectors/packet-dbus.c b/epan/dissectors/packet-dbus.c
index 4fd951c90f..a6a3d33fa7 100644
--- a/epan/dissectors/packet-dbus.c
+++ b/epan/dissectors/packet-dbus.c
@@ -698,8 +698,7 @@ reader_next(dbus_type_reader_t *reader, int hf, int ett, dbus_val_t *value) {
is_single_complete_type = TRUE;
} else if (array_len <= DBUS_MAX_ARRAY_LEN) {
int end_offset = ptvcursor_current_offset(packet->cursor) + array_len;
- dbus_type_reader_t *child = (dbus_type_reader_t *)wmem_alloc(
- wmem_packet_scope(), sizeof(dbus_type_reader_t));
+ dbus_type_reader_t *child = wmem_new(wmem_packet_scope(), dbus_type_reader_t);
*child = (dbus_type_reader_t){
.packet = reader->packet,
.signature = reader->signature,
@@ -722,8 +721,7 @@ reader_next(dbus_type_reader_t *reader, int hf, int ett, dbus_val_t *value) {
is_single_complete_type = FALSE;
ptvcursor_add_with_subtree(packet->cursor, hf != -1 ? hf : hf_dbus_type_struct,
SUBTREE_UNDEFINED_LENGTH, ENC_NA, ett != -1 ? ett : ett_dbus_type_struct);
- dbus_type_reader_t *child = (dbus_type_reader_t *)wmem_alloc(
- wmem_packet_scope(), sizeof(dbus_type_reader_t));
+ dbus_type_reader_t *child = wmem_new(wmem_packet_scope(), dbus_type_reader_t);
*child = (dbus_type_reader_t){
.packet = reader->packet,
.signature = reader->signature,
@@ -742,8 +740,7 @@ reader_next(dbus_type_reader_t *reader, int hf, int ett, dbus_val_t *value) {
const char *variant_signature = add_dbus_string(packet, hf_dbus_type_variant_signature, 1);
value->string = variant_signature;
if (variant_signature && is_dbus_signature_valid(variant_signature)) {
- dbus_type_reader_t *child = (dbus_type_reader_t *)wmem_alloc(
- wmem_packet_scope(), sizeof(dbus_type_reader_t));
+ dbus_type_reader_t *child = wmem_new(wmem_packet_scope(), dbus_type_reader_t);
*child = (dbus_type_reader_t){
.packet = reader->packet,
.signature = variant_signature,
@@ -770,8 +767,7 @@ reader_next(dbus_type_reader_t *reader, int hf, int ett, dbus_val_t *value) {
proto_item *dict_entry = ptvcursor_add_with_subtree(packet->cursor,
hf != -1 ? hf : hf_dbus_type_dict_entry,
SUBTREE_UNDEFINED_LENGTH, ENC_NA, ett != -1 ? ett : ett_dbus_type_dict_entry);
- dbus_type_reader_t *child = (dbus_type_reader_t *)wmem_alloc(
- wmem_packet_scope(), sizeof(dbus_type_reader_t));
+ dbus_type_reader_t *child = wmem_new(wmem_packet_scope(), dbus_type_reader_t);
*child = (dbus_type_reader_t){
.packet = reader->packet,
.signature = reader->signature,
diff --git a/epan/dissectors/packet-dcerpc.c b/epan/dissectors/packet-dcerpc.c
index a57b2849eb..a37c51b69c 100644
--- a/epan/dissectors/packet-dcerpc.c
+++ b/epan/dissectors/packet-dcerpc.c
@@ -778,7 +778,7 @@ dcerpc_add_conv_to_bind_table(decode_dcerpc_bind_values_t *binding)
0);
}
- bind_value = (dcerpc_bind_value *)wmem_alloc(wmem_file_scope(), sizeof (dcerpc_bind_value));
+ bind_value = wmem_new(wmem_file_scope(), dcerpc_bind_value);
bind_value->uuid = binding->uuid;
bind_value->ver = binding->ver;
/* For now, assume all DCE/RPC we pick from "decode as" is using
@@ -787,7 +787,7 @@ dcerpc_add_conv_to_bind_table(decode_dcerpc_bind_values_t *binding)
*/
bind_value->transport = uuid_data_repr_proto;
- key = (dcerpc_bind_key *)wmem_alloc(wmem_file_scope(), sizeof (dcerpc_bind_key));
+ key = wmem_new(wmem_file_scope(), dcerpc_bind_key);
key->conv = conv;
key->ctx_id = binding->ctx_id;
key->transport_salt = binding->transport_salt;
@@ -1195,7 +1195,7 @@ void register_dcerpc_auth_subdissector(guint8 auth_level, guint8 auth_type,
if (get_auth_subdissector_fns(auth_level, auth_type))
return;
- d = (dcerpc_auth_subdissector *)g_malloc(sizeof(dcerpc_auth_subdissector));
+ d = g_new(dcerpc_auth_subdissector, 1);
d->auth_level = auth_level;
d->auth_type = auth_type;
@@ -3172,7 +3172,7 @@ add_pointer_to_list(packet_info *pinfo, proto_tree *tree, proto_item *item,
}
}
- npd = (ndr_pointer_data_t *)g_malloc(sizeof(ndr_pointer_data_t));
+ npd = g_new(ndr_pointer_data_t, 1);
npd->id = id;
npd->tree = tree;
npd->item = item;
@@ -3803,7 +3803,7 @@ static dcerpc_auth_context *find_or_create_dcerpc_auth_context(packet_info *pinf
goto return_value;
}
- auth_value = (dcerpc_auth_context *)wmem_alloc(wmem_file_scope(), sizeof (dcerpc_auth_context));
+ auth_value = wmem_new(wmem_file_scope(), dcerpc_auth_context);
if (auth_value == NULL) {
return NULL;
}
@@ -4155,12 +4155,12 @@ dissect_dcerpc_cn_bind(tvbuff_t *tvb, gint offset, packet_info *pinfo,
dcerpc_bind_key *key;
dcerpc_bind_value *value;
- key = (dcerpc_bind_key *)wmem_alloc(wmem_file_scope(), sizeof (dcerpc_bind_key));
+ key = wmem_new(wmem_file_scope(), dcerpc_bind_key);
key->conv = conv;
key->ctx_id = ctx_id;
key->transport_salt = dcerpc_get_transport_salt(pinfo);
- value = (dcerpc_bind_value *)wmem_alloc(wmem_file_scope(), sizeof (dcerpc_bind_value));
+ value = wmem_new(wmem_file_scope(), dcerpc_bind_value);
value->uuid = if_id;
value->ver = if_ver;
value->transport = trans_id;
@@ -4636,7 +4636,7 @@ dissect_dcerpc_cn_rqst(tvbuff_t *tvb, gint offset, packet_info *pinfo,
call_key.call_id = hdr->call_id;
call_key.transport_salt = dcerpc_get_transport_salt(pinfo);
if ((call_value = (dcerpc_call_value *)wmem_map_lookup(dcerpc_cn_calls, &call_key))) {
- new_matched_key = (dcerpc_matched_key *)wmem_alloc(wmem_file_scope(), sizeof (dcerpc_matched_key));
+ new_matched_key = wmem_new(wmem_file_scope(), dcerpc_matched_key);
*new_matched_key = matched_key;
wmem_map_insert(dcerpc_matched, new_matched_key, call_value);
value = call_value;
@@ -4650,7 +4650,7 @@ dissect_dcerpc_cn_rqst(tvbuff_t *tvb, gint offset, packet_info *pinfo,
the call to both the call table and the
matched table
*/
- call_key = (dcerpc_cn_call_key *)wmem_alloc(wmem_file_scope(), sizeof (dcerpc_cn_call_key));
+ call_key = wmem_new(wmem_file_scope(), dcerpc_cn_call_key);
call_key->conv = conv;
call_key->call_id = hdr->call_id;
call_key->transport_salt = dcerpc_get_transport_salt(pinfo);
@@ -4661,7 +4661,7 @@ dissect_dcerpc_cn_rqst(tvbuff_t *tvb, gint offset, packet_info *pinfo,
wmem_map_remove(dcerpc_cn_calls, call_key);
}
- call_value = (dcerpc_call_value *)wmem_alloc(wmem_file_scope(), sizeof (dcerpc_call_value));
+ call_value = wmem_new(wmem_file_scope(), dcerpc_call_value);
call_value->uuid = bind_value->uuid;
call_value->ver = bind_value->ver;
call_value->object_uuid = obj_id;
@@ -4680,7 +4680,7 @@ dissect_dcerpc_cn_rqst(tvbuff_t *tvb, gint offset, packet_info *pinfo,
wmem_map_insert(dcerpc_cn_calls, call_key, call_value);
- new_matched_key = (dcerpc_matched_key *)wmem_alloc(wmem_file_scope(), sizeof (dcerpc_matched_key));
+ new_matched_key = wmem_new(wmem_file_scope(), dcerpc_matched_key);
*new_matched_key = matched_key;
wmem_map_insert(dcerpc_matched, new_matched_key, call_value);
value = call_value;
@@ -4796,7 +4796,7 @@ dissect_dcerpc_cn_resp(tvbuff_t *tvb, gint offset, packet_info *pinfo,
/* extra sanity check, only match them if the reply
came after the request */
if (call_value->req_frame<pinfo->num) {
- new_matched_key = (dcerpc_matched_key *)wmem_alloc(wmem_file_scope(), sizeof (dcerpc_matched_key));
+ new_matched_key = wmem_new(wmem_file_scope(), dcerpc_matched_key);
*new_matched_key = matched_key;
wmem_map_insert(dcerpc_matched, new_matched_key, call_value);
value = call_value;
@@ -4960,7 +4960,7 @@ dissect_dcerpc_cn_fault(tvbuff_t *tvb, gint offset, packet_info *pinfo,
call_key.transport_salt = dcerpc_get_transport_salt(pinfo);
if ((call_value = (dcerpc_call_value *)wmem_map_lookup(dcerpc_cn_calls, &call_key))) {
- new_matched_key = (dcerpc_matched_key *)wmem_alloc(wmem_file_scope(), sizeof (dcerpc_matched_key));
+ new_matched_key = wmem_new(wmem_file_scope(), dcerpc_matched_key);
*new_matched_key = matched_key;
wmem_map_insert(dcerpc_matched, new_matched_key, call_value);
@@ -6207,12 +6207,12 @@ dissect_dcerpc_dg_rqst(tvbuff_t *tvb, int offset, packet_info *pinfo,
dcerpc_call_value *call_value;
dcerpc_dg_call_key *call_key;
- call_key = (dcerpc_dg_call_key *)wmem_alloc(wmem_file_scope(), sizeof (dcerpc_dg_call_key));
+ call_key = wmem_new(wmem_file_scope(), dcerpc_dg_call_key);
call_key->conv = conv;
call_key->seqnum = hdr->seqnum;
call_key->act_id = hdr->act_id;
- call_value = (dcerpc_call_value *)wmem_alloc(wmem_file_scope(), sizeof (dcerpc_call_value));
+ call_value = wmem_new(wmem_file_scope(), dcerpc_call_value);
call_value->uuid = hdr->if_id;
call_value->ver = hdr->if_ver;
call_value->object_uuid = hdr->obj_id;
@@ -6291,7 +6291,7 @@ dissect_dcerpc_dg_resp(tvbuff_t *tvb, int offset, packet_info *pinfo,
call_key.act_id = hdr->act_id;
if ((call_value = (dcerpc_call_value *)wmem_map_lookup(dcerpc_dg_calls, &call_key))) {
- new_matched_key = (dcerpc_matched_key *)wmem_alloc(wmem_file_scope(), sizeof (dcerpc_matched_key));
+ new_matched_key = wmem_new(wmem_file_scope(), dcerpc_matched_key);
new_matched_key->frame = pinfo->num;
new_matched_key->call_id = hdr->seqnum;
wmem_map_insert(dcerpc_matched, new_matched_key, call_value);
diff --git a/epan/dissectors/packet-dpaux.c b/epan/dissectors/packet-dpaux.c
index 53cce1539d..4d4e1c0d0e 100644
--- a/epan/dissectors/packet-dpaux.c
+++ b/epan/dissectors/packet-dpaux.c
@@ -179,8 +179,7 @@ dissect_dpaux_from_source(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
conversation = conversation_new(pinfo->num, &pinfo->src, &pinfo->dst,
ENDPOINT_NONE, pinfo->srcport, pinfo->destport, 0);
- transaction = (struct dpaux_transaction*)wmem_alloc(wmem_file_scope(),
- sizeof(struct dpaux_transaction));
+ transaction = wmem_new(wmem_file_scope(), struct dpaux_transaction);
transaction->is_native = type;
transaction->addr = addr;
diff --git a/epan/dissectors/packet-exported_pdu.c b/epan/dissectors/packet-exported_pdu.c
index 540fae45fa..490e4b3e7e 100644
--- a/epan/dissectors/packet-exported_pdu.c
+++ b/epan/dissectors/packet-exported_pdu.c
@@ -266,7 +266,7 @@ dissect_exported_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void*
break;
case EXP_PDU_TAG_SS7_OPC:
proto_tree_add_item(tag_tree, hf_exported_pdu_ss7_opc, tvb, offset, 4, ENC_BIG_ENDIAN);
- mtp3_addr = (mtp3_addr_pc_t *)wmem_alloc0(pinfo->pool, sizeof(mtp3_addr_pc_t));
+ mtp3_addr = wmem_new0(pinfo->pool, mtp3_addr_pc_t);
mtp3_addr->pc = tvb_get_ntohl(tvb, offset);
mtp3_addr->type = (Standard_Type)tvb_get_ntohs(tvb, offset+4);
mtp3_addr->ni = tvb_get_guint8(tvb, offset+6);
@@ -274,7 +274,7 @@ dissect_exported_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void*
break;
case EXP_PDU_TAG_SS7_DPC:
proto_tree_add_item(tag_tree, hf_exported_pdu_ss7_dpc, tvb, offset, 4, ENC_BIG_ENDIAN);
- mtp3_addr = (mtp3_addr_pc_t *)wmem_alloc0(pinfo->pool, sizeof(mtp3_addr_pc_t));
+ mtp3_addr = wmem_new0(pinfo->pool, mtp3_addr_pc_t);
mtp3_addr->pc = tvb_get_ntohl(tvb, offset);
mtp3_addr->type = (Standard_Type)tvb_get_ntohs(tvb, offset+4);
mtp3_addr->ni = tvb_get_guint8(tvb, offset+6);
diff --git a/epan/dissectors/packet-fpp.c b/epan/dissectors/packet-fpp.c
index dd9514520d..25a0443551 100644
--- a/epan/dissectors/packet-fpp.c
+++ b/epan/dissectors/packet-fpp.c
@@ -368,7 +368,7 @@ dissect_preemption(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32
if (!PINFO_FD_VISITED(pinfo)) {
// Fist delete previous conversation
drop_conversation(conv);
- ctx = (struct _fpp_ctx_t *)wmem_alloc(wmem_file_scope(), sizeof(struct _fpp_ctx_t));
+ ctx = wmem_new(wmem_file_scope(), struct _fpp_ctx_t);
init_fpp_ctx(ctx, get_cont_by_start(smd2));
ctx->size = frag_size;
conversation_add_proto_data(conv, proto_fpp, ctx);
diff --git a/epan/dissectors/packet-giop.c b/epan/dissectors/packet-giop.c
index 2f211a7d90..0226f97249 100644
--- a/epan/dissectors/packet-giop.c
+++ b/epan/dissectors/packet-giop.c
@@ -1337,12 +1337,12 @@ void register_giop_user_module(giop_sub_dissector_t *sub, const gchar *name, con
ws_debug_printf("giop:register_module: Module sub dissector name is %s \n", name);
#endif
- new_module_key = (struct giop_module_key *)wmem_alloc(wmem_epan_scope(), sizeof(struct giop_module_key));
+ new_module_key = wmem_new(wmem_epan_scope(), struct giop_module_key);
new_module_key->module = module; /* save Module or interface name from IDL */
- module_val = (struct giop_module_val *)wmem_alloc(wmem_epan_scope(), sizeof(struct giop_module_val));
+ module_val = wmem_new(wmem_epan_scope(), struct giop_module_val);
- module_val->subh = (giop_sub_handle_t *)wmem_alloc(wmem_epan_scope(), sizeof (giop_sub_handle_t)); /* init subh */
+ module_val->subh = wmem_new(wmem_epan_scope(), giop_sub_handle_t); /* init subh */
module_val->subh->sub_name = name; /* save dissector name */
module_val->subh->sub_fn = sub; /* save subdissector*/
@@ -1615,7 +1615,7 @@ void register_giop_user(giop_sub_dissector_t *sub, const gchar *name, int sub_pr
giop_sub_handle_t *subh;
- subh = (giop_sub_handle_t *)wmem_alloc(wmem_epan_scope(), sizeof (giop_sub_handle_t));
+ subh = wmem_new(wmem_epan_scope(), giop_sub_handle_t);
subh->sub_name = name;
subh->sub_fn = sub;
diff --git a/epan/dissectors/packet-hpfeeds.c b/epan/dissectors/packet-hpfeeds.c
index 66ff034dbb..a5abc14f56 100644
--- a/epan/dissectors/packet-hpfeeds.c
+++ b/epan/dissectors/packet-hpfeeds.c
@@ -230,7 +230,7 @@ static tap_packet_status hpfeeds_stats_tree_packet(stats_tree* st _U_, packet_in
}
if (cur == NULL) {
- ch_node = (struct channel_node*)wmem_alloc0(wmem_file_scope(), sizeof(struct channel_node));
+ ch_node = wmem_new0(wmem_file_scope(), struct channel_node);
ch_node->channel = wmem_strdup(wmem_file_scope(), pi->channel);
ch_node->st_node_channel_payload = stats_tree_create_node(st, ch_node->channel,
st_node_channels_payload, STAT_DT_INT, FALSE);
diff --git a/epan/dissectors/packet-idn.c b/epan/dissectors/packet-idn.c
index 0458f8d595..6330a6ded1 100644
--- a/epan/dissectors/packet-idn.c
+++ b/epan/dissectors/packet-idn.c
@@ -937,7 +937,7 @@ static int dissect_idn_message_header(tvbuff_t *tvb, int offset, proto_tree *idn
static int dissect_idn_message(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *idn_tree) {
int scm;
configuration_info *config = NULL;
- message_info *minfo = (message_info *)wmem_alloc(wmem_file_scope(), sizeof(message_info));
+ message_info *minfo = wmem_new(wmem_file_scope(), message_info);
offset = dissect_idn_message_header(tvb, offset, idn_tree, minfo);
determine_message_type(pinfo, minfo);
@@ -945,7 +945,7 @@ static int dissect_idn_message(tvbuff_t *tvb, packet_info *pinfo, int offset, pr
return offset;
if(minfo->has_config_header && minfo->chunk_type != IDNCT_LP_FRAME_SF) {
- config = (configuration_info *)wmem_alloc0(wmem_file_scope(), sizeof(configuration_info));
+ config = wmem_new0(wmem_file_scope(), configuration_info);
offset = dissect_idn_channel_configuration(tvb, pinfo, offset, idn_tree, minfo, config);
}else if(minfo->chunk_type != IDNCT_VOID) {
config = get_configuration_info(pinfo, minfo->channel_id);
diff --git a/epan/dissectors/packet-ieee802a.c b/epan/dissectors/packet-ieee802a.c
index 4e68ddcca6..0d78073051 100644
--- a/epan/dissectors/packet-ieee802a.c
+++ b/epan/dissectors/packet-ieee802a.c
@@ -46,7 +46,7 @@ ieee802a_add_oui(guint32 oui, const char *table_name, const char *table_ui_name,
{
oui_info_t *new_info;
- new_info = (oui_info_t *)g_malloc(sizeof (oui_info_t));
+ new_info = g_new(oui_info_t, 1);
new_info->table = register_dissector_table(table_name,
table_ui_name, proto, FT_UINT16, BASE_HEX);
new_info->field_info = hf_item;
diff --git a/epan/dissectors/packet-imf.c b/epan/dissectors/packet-imf.c
index 18c1352d04..1ad5c83d70 100644
--- a/epan/dissectors/packet-imf.c
+++ b/epan/dissectors/packet-imf.c
@@ -973,11 +973,11 @@ header_fields_post_update_cb (void)
if (num_header_fields) {
custom_field_table = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, free_imf_field);
- dynamic_hf = (hf_register_info *)g_malloc0 (sizeof (hf_register_info) * num_header_fields);
+ dynamic_hf = g_new0(hf_register_info, num_header_fields);
dynamic_hf_size = num_header_fields;
for (guint i = 0; i < dynamic_hf_size; i++) {
- hf_id = (gint *)g_malloc (sizeof (gint));
+ hf_id = g_new(gint, 1);
*hf_id = -1;
header_name = g_strdup (header_fields[i].header_name);
@@ -991,7 +991,7 @@ header_fields_post_update_cb (void)
dynamic_hf[i].hfinfo.blurb = g_strdup (header_fields[i].description);
HFILL_INIT(dynamic_hf[i]);
- imffield = (struct imf_field *)g_malloc (sizeof (struct imf_field));
+ imffield = g_new(struct imf_field, 1);
imffield->hf_id = hf_id;
imffield->name = g_ascii_strdown(header_name, -1);
switch (header_fields[i].header_format) {
diff --git a/epan/dissectors/packet-infiniband.c b/epan/dissectors/packet-infiniband.c
index d2d8809703..ad58ed6235 100644
--- a/epan/dissectors/packet-infiniband.c
+++ b/epan/dissectors/packet-infiniband.c
@@ -3325,10 +3325,10 @@ static void save_conversation_info(packet_info *pinfo, guint8 *local_gid, guint8
connection_context *connection;
conversation_infiniband_data *proto_data;
conversation_t *conv;
- guint64 *hash_key = (guint64 *)g_malloc(sizeof(guint64));
+ guint64 *hash_key = g_new(guint64, 1);
/* create a new connection context and store it in the hash table */
- connection = (connection_context *)g_malloc(sizeof(connection_context));
+ connection = g_new(connection_context, 1);
if (pinfo->dst.type == AT_IPv4) {
memcpy(&(connection->req_gid), local_gid, 4);
diff --git a/epan/dissectors/packet-ipmi.c b/epan/dissectors/packet-ipmi.c
index 7fc4e13058..91ab7655b8 100644
--- a/epan/dissectors/packet-ipmi.c
+++ b/epan/dissectors/packet-ipmi.c
@@ -1122,7 +1122,7 @@ ipmi_register_netfn_cmdtab(guint32 netfn, guint oem_selector,
return;
}
- inh = (struct ipmi_netfn_handler *)wmem_alloc(wmem_epan_scope(), sizeof(struct ipmi_netfn_handler));
+ inh = wmem_new(wmem_epan_scope(), struct ipmi_netfn_handler);
inh->desc = desc;
inh->oem_selector = oem_selector;
inh->sig = sig;
diff --git a/epan/dissectors/packet-ipsec.c b/epan/dissectors/packet-ipsec.c
index 2b736ddcad..63acc3c1f6 100644
--- a/epan/dissectors/packet-ipsec.c
+++ b/epan/dissectors/packet-ipsec.c
@@ -404,7 +404,7 @@ void esp_sa_record_add_from_dissector(guint8 protocol, const gchar *srcIP, const
{
uat_esp_sa_record_t* record = NULL;
if (extra_esp_sa_records.num_records == 0) {
- extra_esp_sa_records.records = (uat_esp_sa_record_t *)g_malloc(sizeof(uat_esp_sa_record_t)*MAX_EXTRA_SA_RECORDS);
+ extra_esp_sa_records.records = g_new(uat_esp_sa_record_t, MAX_EXTRA_SA_RECORDS);
}
if (extra_esp_sa_records.num_records < MAX_EXTRA_SA_RECORDS) {
record = &extra_esp_sa_records.records[extra_esp_sa_records.num_records++];
diff --git a/epan/dissectors/packet-k12.c b/epan/dissectors/packet-k12.c
index cf43175b40..dd08af5423 100644
--- a/epan/dissectors/packet-k12.c
+++ b/epan/dissectors/packet-k12.c
@@ -301,7 +301,7 @@ k12_update_cb(void* r, char** err)
g_free(h->handles);
/* Allocate extra space for NULL marker */
- h->handles = (dissector_handle_t *)g_malloc0(sizeof(dissector_handle_t)*(num_protos+1));
+ h->handles = g_new0(dissector_handle_t, (num_protos+1));
for (i = 0; i < num_protos; i++) {
if ( ! (h->handles[i] = find_dissector(protos[i])) ) {
diff --git a/epan/dissectors/packet-mac-lte-framed.c b/epan/dissectors/packet-mac-lte-framed.c
index b901add561..0a805513af 100644
--- a/epan/dissectors/packet-mac-lte-framed.c
+++ b/epan/dissectors/packet-mac-lte-framed.c
@@ -51,7 +51,7 @@ static int dissect_mac_lte_framed(tvbuff_t *tvb, packet_info *pinfo,
p_mac_lte_info = (struct mac_lte_info*)p_get_proto_data(wmem_file_scope(), pinfo, proto_mac_lte, 0);
if (p_mac_lte_info == NULL) {
/* Allocate new info struct for this frame */
- p_mac_lte_info = (struct mac_lte_info*)wmem_alloc0(wmem_file_scope(), sizeof(struct mac_lte_info));
+ p_mac_lte_info = wmem_new0(wmem_file_scope(), struct mac_lte_info);
infoAlreadySet = FALSE;
}
else {
diff --git a/epan/dissectors/packet-mswsp.c b/epan/dissectors/packet-mswsp.c
index 09d412bf06..37ad06c2b2 100644
--- a/epan/dissectors/packet-mswsp.c
+++ b/epan/dissectors/packet-mswsp.c
@@ -755,7 +755,7 @@ static struct message_data *find_or_create_message_data(struct mswsp_ct *conv_da
result = g_slist_find_custom(conv_data->GSL_message_data,
&to_find, (GCompareFunc)msg_data_find);
if (!result) {
- msg_data = (struct message_data *)wmem_alloc(wmem_file_scope(), sizeof(struct message_data));
+ msg_data = wmem_new(wmem_file_scope(), struct message_data);
*msg_data = to_find;
conv_data->GSL_message_data = g_slist_prepend(conv_data->GSL_message_data, msg_data);
} else {
diff --git a/epan/dissectors/packet-mtp3.c b/epan/dissectors/packet-mtp3.c
index 559e95a8eb..a04b017047 100644
--- a/epan/dissectors/packet-mtp3.c
+++ b/epan/dissectors/packet-mtp3.c
@@ -781,8 +781,8 @@ dissect_mtp3(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
/* create display subtree for the protocol */
mtp3_tree = proto_item_add_subtree(mtp3_item, ett_mtp3);
- mtp3_addr_opc = (mtp3_addr_pc_t *)wmem_alloc0(pinfo->pool, sizeof(mtp3_addr_pc_t));
- mtp3_addr_dpc = (mtp3_addr_pc_t *)wmem_alloc0(pinfo->pool, sizeof(mtp3_addr_pc_t));
+ mtp3_addr_opc = wmem_new0(pinfo->pool, mtp3_addr_pc_t);
+ mtp3_addr_dpc = wmem_new0(pinfo->pool, mtp3_addr_pc_t);
/* Dissect the packet (even if !tree so can call sub-dissectors and update
* the source and destination address columns) */
diff --git a/epan/dissectors/packet-nano.c b/epan/dissectors/packet-nano.c
index b0cbbacd66..fe687835f9 100644
--- a/epan/dissectors/packet-nano.c
+++ b/epan/dissectors/packet-nano.c
@@ -743,7 +743,7 @@ static int dissect_nano_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
session_state = (struct nano_session_state *)conversation_get_proto_data(conversation, proto_nano);
if (!session_state) {
// create new session state
- session_state = (struct nano_session_state *)wmem_alloc0(wmem_file_scope(), sizeof(struct nano_session_state));
+ session_state = wmem_new0(wmem_file_scope(), struct nano_session_state);
session_state->client_packet_type = NANO_PACKET_TYPE_INVALID;
session_state->server_port = pinfo->match_uint;
conversation_add_proto_data(conversation, proto_nano, session_state);
@@ -753,7 +753,7 @@ static int dissect_nano_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
packet_session_state = (struct nano_session_state *)p_get_proto_data(wmem_file_scope(), pinfo, proto_nano, 0);
if (!packet_session_state) {
// this packet does not have a stored session state, get it from the conversation
- packet_session_state = (struct nano_session_state *)wmem_alloc0(wmem_file_scope(), sizeof(struct nano_session_state));
+ packet_session_state = wmem_new0(wmem_file_scope(), struct nano_session_state);
memcpy(packet_session_state, session_state, sizeof(struct nano_session_state));
p_add_proto_data(wmem_file_scope(), pinfo, proto_nano, 0, packet_session_state);
} else {
@@ -827,7 +827,7 @@ static gboolean dissect_nano_heur_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_t
session_state = (struct nano_session_state *)conversation_get_proto_data(conversation, proto_nano);
if (!session_state) {
// create new session state
- session_state = (struct nano_session_state *)wmem_alloc0(wmem_file_scope(), sizeof(struct nano_session_state));
+ session_state = wmem_new0(wmem_file_scope(), struct nano_session_state);
session_state->client_packet_type = NANO_PACKET_TYPE_INVALID;
session_state->server_port = pinfo->destport;
conversation_add_proto_data(conversation, proto_nano, session_state);
diff --git a/epan/dissectors/packet-nvme-tcp.c b/epan/dissectors/packet-nvme-tcp.c
index 8bd868bd65..40180eb9c5 100644
--- a/epan/dissectors/packet-nvme-tcp.c
+++ b/epan/dissectors/packet-nvme-tcp.c
@@ -1118,8 +1118,7 @@ dissect_nvme_tcp_pdu(tvbuff_t *tvb,
conversation_get_proto_data(conversation, proto_nvme_tcp);
if (!q_ctx) {
- q_ctx = (struct nvme_tcp_q_ctx *) wmem_alloc0(wmem_file_scope(),
- sizeof(struct nvme_tcp_q_ctx));
+ q_ctx = wmem_new0(wmem_file_scope(), struct nvme_tcp_q_ctx);
q_ctx->n_q_ctx.pending_cmds = wmem_tree_new(wmem_file_scope());
q_ctx->n_q_ctx.done_cmds = wmem_tree_new(wmem_file_scope());
q_ctx->n_q_ctx.data_requests = wmem_tree_new(wmem_file_scope());
diff --git a/epan/dissectors/packet-radius.c b/epan/dissectors/packet-radius.c
index b745619407..6a88193582 100644
--- a/epan/dissectors/packet-radius.c
+++ b/epan/dissectors/packet-radius.c
@@ -1677,7 +1677,7 @@ dissect_attribute_value_pairs(proto_tree *tree, packet_info *pinfo, tvbuff_t *tv
if (avp_vsa_flags & 0x80) {
if (!vsa_buffer) {
- vsa_buffer = (radius_vsa_buffer *)g_malloc(sizeof(radius_vsa_buffer));
+ vsa_buffer = g_new(radius_vsa_buffer, 1);
vsa_buffer->key.vendor_id = vendor_id;
vsa_buffer->key.vsa_type = avp_vsa_type;
vsa_buffer->len = avp_vsa_len;
@@ -2482,7 +2482,7 @@ radius_register_avp_dissector(guint32 vendor_id, guint32 _attribute_id, radius_a
vendor = (radius_vendor_info_t *)g_hash_table_lookup(dict->vendors_by_id, GUINT_TO_POINTER(vendor_id));
if (!vendor) {
- vendor = (radius_vendor_info_t *)g_malloc(sizeof(radius_vendor_info_t));
+ vendor = g_new(radius_vendor_info_t, 1);
vendor->name = g_strdup_printf("%s-%u",
enterprises_lookup(vendor_id, "Unknown"),
@@ -2508,7 +2508,7 @@ radius_register_avp_dissector(guint32 vendor_id, guint32 _attribute_id, radius_a
}
if (!dictionary_entry) {
- dictionary_entry = (radius_attr_info_t *)g_malloc(sizeof(radius_attr_info_t));
+ dictionary_entry = g_new(radius_attr_info_t, 1);
dictionary_entry->name = g_strdup_printf("Unknown-Attribute-%u", attribute_id.value);
dictionary_entry->code = attribute_id;
@@ -2849,7 +2849,7 @@ proto_register_radius(void)
radius_tap = register_tap("radius");
proto_register_prefix("radius", register_radius_fields);
- dict = (radius_dictionary_t *)g_malloc(sizeof(radius_dictionary_t));
+ dict = g_new(radius_dictionary_t, 1);
/*
* IDs map to names and vice versa. The attribute and vendor is stored
* only once, but referenced by both name and ID mappings.
diff --git a/epan/dissectors/packet-rpc.c b/epan/dissectors/packet-rpc.c
index 79ec7bd033..5a9a22544e 100644
--- a/epan/dissectors/packet-rpc.c
+++ b/epan/dissectors/packet-rpc.c
@@ -521,7 +521,7 @@ rpc_init_prog(int proto, guint32 prog, int ett, size_t nvers,
size_t versidx;
const vsff *proc;
- value = (rpc_prog_info_value *) g_malloc(sizeof(rpc_prog_info_value));
+ value = g_new(rpc_prog_info_value, 1);
value->proto = find_protocol_by_id(proto);
value->proto_id = proto;
value->ett = ett;
diff --git a/epan/dissectors/packet-sctp.c b/epan/dissectors/packet-sctp.c
index 92b80ad836..a9c0cc9abc 100644
--- a/epan/dissectors/packet-sctp.c
+++ b/epan/dissectors/packet-sctp.c
@@ -2762,7 +2762,7 @@ add_fragment(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 tsn,
msg = find_message(stream_id, stream_seq_num, u_bit);
if (!msg) {
- msg = (sctp_frag_msg *)g_malloc (sizeof (sctp_frag_msg));
+ msg = g_new(sctp_frag_msg, 1);
msg->begins = NULL;
msg->ends = NULL;
msg->fragments = NULL;
@@ -2776,7 +2776,7 @@ add_fragment(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 tsn,
else
msg->ppi = ppi;
- key = (frag_key *)g_malloc(sizeof (frag_key));
+ key = g_new(frag_key, 1);
key->sport = sctp_info.sport;
key->dport = sctp_info.dport;
key->verification_tag = sctp_info.verification_tag;
@@ -2820,7 +2820,7 @@ add_fragment(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 tsn,
return NULL;
/* create new fragment */
- fragment = (sctp_fragment *)g_malloc (sizeof (sctp_fragment));
+ fragment = g_new(sctp_fragment, 1);
fragment->frame_num = pinfo->num;
fragment->tsn = tsn;
fragment->len = tvb_captured_length(tvb);
@@ -2850,7 +2850,7 @@ add_fragment(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 tsn,
/* save begin or end if necessary */
if (b_bit && !e_bit) {
- beginend = (sctp_frag_be *)g_malloc (sizeof (sctp_frag_be));
+ beginend = g_new(sctp_frag_be, 1);
beginend->fragment = fragment;
beginend->next = NULL;
@@ -2875,7 +2875,7 @@ add_fragment(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 tsn,
}
if (!b_bit && e_bit) {
- beginend = (sctp_frag_be *)g_malloc (sizeof (sctp_frag_be));
+ beginend = g_new(sctp_frag_be, 1);
beginend->fragment = fragment;
beginend->next = NULL;
diff --git a/epan/dissectors/packet-smb.c b/epan/dissectors/packet-smb.c
index 39fe67a400..66f0349ac6 100644
--- a/epan/dissectors/packet-smb.c
+++ b/epan/dissectors/packet-smb.c
@@ -1286,7 +1286,7 @@ smb_eo_packet(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_, const
entry = g_new(export_object_entry_t, 1);
entry->payload_data = NULL;
entry->payload_len = 0;
- new_file = (active_file *)g_malloc(sizeof(active_file));
+ new_file = g_new(active_file, 1);
new_file->tid = incoming_file.tid;
new_file->uid = incoming_file.uid;
new_file->fid = incoming_file.fid;
@@ -18010,7 +18010,7 @@ dissect_smb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* da
si->ct = (conv_tables_t *)conversation_get_proto_data(conversation, proto_smb);
if (!si->ct) {
/* No, not yet. create it and attach it to the conversation */
- si->ct = (conv_tables_t *)g_malloc(sizeof(conv_tables_t));
+ si->ct = g_new(conv_tables_t, 1);
conv_tables = g_slist_prepend(conv_tables, si->ct);
si->ct->matched = g_hash_table_new(smb_saved_info_hash_matched,
diff --git a/epan/dissectors/packet-smtp.c b/epan/dissectors/packet-smtp.c
index 096b6780cf..f83cca3689 100644
--- a/epan/dissectors/packet-smtp.c
+++ b/epan/dissectors/packet-smtp.c
@@ -429,7 +429,7 @@ dissect_smtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
/*
* No - create one and attach it.
*/
- session_state = (struct smtp_session_state *)wmem_alloc0(wmem_file_scope(), sizeof(struct smtp_session_state));
+ session_state = wmem_new0(wmem_file_scope(), struct smtp_session_state);
session_state->smtp_state = SMTP_STATE_START;
session_state->auth_state = SMTP_AUTH_STATE_NONE;
session_state->msg_last = TRUE;
@@ -455,7 +455,7 @@ dissect_smtp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
/*
* Create a frame data structure and attach it to the packet.
*/
- spd_frame_data = (struct smtp_proto_data *)wmem_alloc0(wmem_file_scope(), sizeof(struct smtp_proto_data));
+ spd_frame_data = wmem_new0(wmem_file_scope(), struct smtp_proto_data);
spd_frame_data->conversation_id = conversation->conv_index;
spd_frame_data->more_frags = TRUE;
diff --git a/epan/dissectors/packet-snort-config.c b/epan/dissectors/packet-snort-config.c
index 1bf3f42d9a..0ced5c7407 100644
--- a/epan/dissectors/packet-snort-config.c
+++ b/epan/dissectors/packet-snort-config.c
@@ -741,7 +741,7 @@ static gboolean parse_rule(SnortConfig_t *snort_config, char *line, const char *
}
/* Allocate the rule itself */
- rule = (Rule_t*)g_malloc(sizeof(Rule_t));
+ rule = g_new(Rule_t, 1);
snort_debug_printf("looks like a rule: %s\n", line);
memset(rule, 0, sizeof(Rule_t));
@@ -905,7 +905,7 @@ void create_config(SnortConfig_t **snort_config, const char *snort_config_file)
snort_debug_printf("create_config (%s)\n", snort_config_file);
- *snort_config = (SnortConfig_t*)g_malloc(sizeof(SnortConfig_t));
+ *snort_config = g_new(SnortConfig_t, 1);
memset(*snort_config, 0, sizeof(SnortConfig_t));
/* Create rule table */
diff --git a/epan/dissectors/packet-snort.c b/epan/dissectors/packet-snort.c
index 2add440baf..5d9f1efe71 100644
--- a/epan/dissectors/packet-snort.c
+++ b/epan/dissectors/packet-snort.c
@@ -211,7 +211,7 @@ static void add_alert_to_session_tree(guint frame_number, Alert_t *alert)
Alerts_t *alerts = (Alerts_t*)wmem_tree_lookup32(current_session.alerts_tree, frame_number);
if (alerts == NULL) {
/* Create a new entry for the table */
- alerts = (Alerts_t*)g_malloc(sizeof(Alerts_t));
+ alerts = g_new(Alerts_t, 1);
/* Deep copy of alert */
alerts->alerts[0] = *alert;
alerts->num_alerts = 1;
diff --git a/epan/dissectors/packet-soupbintcp.c b/epan/dissectors/packet-soupbintcp.c
index 8a89ae0ba5..50eb41026a 100644
--- a/epan/dissectors/packet-soupbintcp.c
+++ b/epan/dissectors/packet-soupbintcp.c
@@ -205,7 +205,7 @@ dissect_soupbintcp_common(
0);
/* Store starting sequence number for session's packets */
- conv_data = (struct conv_data *)wmem_alloc(wmem_file_scope(), sizeof(struct conv_data));
+ conv_data = wmem_new(wmem_file_scope(), struct conv_data);
conv_data->next_seq = next_seq;
conversation_add_proto_data(conv, proto_soupbintcp, conv_data);
}
@@ -226,9 +226,7 @@ dissect_soupbintcp_common(
this_seq = 0;
}
- pdu_data = (struct pdu_data *)wmem_alloc(
- wmem_file_scope(),
- sizeof(struct pdu_data));
+ pdu_data = wmem_new(wmem_file_scope(), struct pdu_data);
pdu_data->seq_num = this_seq;
p_add_proto_data(wmem_file_scope(), pinfo, proto_soupbintcp, key, pdu_data);
}
diff --git a/epan/dissectors/packet-ssh.c b/epan/dissectors/packet-ssh.c
index 6b05061991..e909b437d2 100644
--- a/epan/dissectors/packet-ssh.c
+++ b/epan/dissectors/packet-ssh.c
@@ -458,7 +458,7 @@ dissect_ssh(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
global_data = (struct ssh_flow_data *)conversation_get_proto_data(conversation, proto_ssh);
if (!global_data) {
- global_data = (struct ssh_flow_data *)wmem_alloc0(wmem_file_scope(), sizeof(struct ssh_flow_data));
+ global_data = wmem_new0(wmem_file_scope(), struct ssh_flow_data);
global_data->version = SSH_VERSION_UNKNOWN;
global_data->kex_specific_dissector = ssh_dissect_kex_dh;
global_data->peer_data[CLIENT_PEER_DATA].mac_length = -1;
diff --git a/epan/dissectors/packet-tpncp.c b/epan/dissectors/packet-tpncp.c
index 9b83e8d84c..3209042b40 100644
--- a/epan/dissectors/packet-tpncp.c
+++ b/epan/dissectors/packet-tpncp.c
@@ -801,8 +801,7 @@ init_tpncp_data_fields_info(tpncp_data_field_info *data_fields_info, FILE *file)
field = &data_fields_info[data_id];
current_data_id = data_id;
} else {
- field->p_next = (tpncp_data_field_info *) wmem_alloc(
- wmem_epan_scope(), sizeof (tpncp_data_field_info));
+ field->p_next = wmem_new(wmem_epan_scope(), tpncp_data_field_info);
if (!field->p_next)
return (-1);
field = field->p_next;
diff --git a/epan/dissectors/packet-twamp.c b/epan/dissectors/packet-twamp.c
index cd135fa61c..c2f13c269f 100644
--- a/epan/dissectors/packet-twamp.c
+++ b/epan/dissectors/packet-twamp.c
@@ -251,7 +251,7 @@ dissect_twamp_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void
/* try to find session from past visits */
if ((list = g_slist_find_custom(ct->sessions, &sender_port,
(GCompareFunc) find_twamp_session_by_sender_port)) == NULL) {
- session = (twamp_session_t *) g_malloc0(sizeof(twamp_session_t));
+ session = g_new0(twamp_session_t, 1);
session->sender_port = sender_port;
session->receiver_port = receiver_port;
session->accepted = 0;
diff --git a/epan/dissectors/packet-umts_rlc.c b/epan/dissectors/packet-umts_rlc.c
index 222a88eacb..e453c77ac3 100644
--- a/epan/dissectors/packet-umts_rlc.c
+++ b/epan/dissectors/packet-umts_rlc.c
@@ -378,7 +378,7 @@ rlc_channel_create(enum rlc_mode mode, packet_info *pinfo, struct atm_phdr *atm)
struct rlc_channel *ch;
int rv;
- ch = (struct rlc_channel *)g_malloc0(sizeof(struct rlc_channel));
+ ch = g_new0(struct rlc_channel, 1);
rv = rlc_channel_assign(ch, mode, pinfo, atm);
if (rv != 0) {
@@ -423,7 +423,7 @@ rlc_sdu_create(void)
{
struct rlc_sdu *sdu;
- sdu = (struct rlc_sdu *)wmem_alloc0(wmem_file_scope(), sizeof(struct rlc_sdu));
+ sdu = wmem_new0(wmem_file_scope(), struct rlc_sdu);
return sdu;
}
@@ -484,7 +484,7 @@ rlc_frag_create(tvbuff_t *tvb, enum rlc_mode mode, packet_info *pinfo,
{
struct rlc_frag *frag;
- frag = (struct rlc_frag *)wmem_alloc0(wmem_file_scope(), sizeof(struct rlc_frag));
+ frag = wmem_new0(wmem_file_scope(), struct rlc_frag);
rlc_frag_assign(frag, mode, pinfo, seq, li, atm);
rlc_frag_assign_data(frag, tvb, offset, length);
@@ -1302,7 +1302,7 @@ rlc_is_duplicate(enum rlc_mode mode, packet_info *pinfo, guint16 seq,
}
if(is_unseen) {
/* Add to list for the first time this frame is checked */
- seq_new = (struct rlc_seq *)wmem_alloc0(wmem_file_scope(), sizeof(struct rlc_seq));
+ seq_new = wmem_new0(wmem_file_scope(), struct rlc_seq);
*seq_new = seq_item;
seq_new->arrival = pinfo->abs_ts;
list->list = g_list_append(list->list, seq_new); /* insert in order of arrival */
@@ -1603,7 +1603,7 @@ rlc_decipher(tvbuff_t *tvb, packet_info * pinfo, proto_tree * tree, fp_info * fp
if(!tree){
/*Preserve counter value for next dissection round*/
guint32 * ciph;
- ciph = (guint32 *)g_malloc(sizeof(guint32)*2);
+ ciph = g_new(guint32, 2);
ciph[0] = ps_counter[rlcinf->rbid[pos]][0];
ciph[1] = ps_counter[rlcinf->rbid[pos]][1];
g_tree_insert(counter_map, GINT_TO_POINTER((gint)pinfo->num), ciph);
@@ -1643,7 +1643,7 @@ rlc_decipher(tvbuff_t *tvb, packet_info * pinfo, proto_tree * tree, fp_info * fp
if(!tree){/*Preserve counter for second packet analysis run*/
guint32 * ciph;
- ciph = (guint32 *)g_malloc(sizeof(guint32)*2);
+ ciph = g_new(guint32, 2);
ciph[0] = ps_counter[rlcinf->rbid[pos]][0];
ciph[1] = ps_counter[rlcinf->rbid[pos]][1];
g_tree_insert(counter_map, GINT_TO_POINTER((gint)pinfo->num+1), ciph);
diff --git a/epan/dissectors/packet-zvt.c b/epan/dissectors/packet-zvt.c
index e7f714a67c..80e8078027 100644
--- a/epan/dissectors/packet-zvt.c
+++ b/epan/dissectors/packet-zvt.c
@@ -477,8 +477,7 @@ dissect_zvt_tlv_seq(tvbuff_t *tvb, gint offset, guint16 seq_max_len,
gint ret;
if (!seq_info) {
- seq_info = (tlv_seq_info_t *)wmem_alloc(
- wmem_packet_scope(), sizeof(tlv_seq_info_t));
+ seq_info = wmem_new(wmem_packet_scope(), tlv_seq_info_t);
/* by default, text lines are using the CP437 charset
there's an object to change the encoding
diff --git a/epan/funnel.c b/epan/funnel.c
index 0ca21b8bb2..5e8cb24029 100644
--- a/epan/funnel.c
+++ b/epan/funnel.c
@@ -95,7 +95,7 @@ void funnel_register_menu(const char *name,
funnel_menu_callback_data_free callback_data_free,
gboolean retap)
{
- funnel_menu_t* m = (funnel_menu_t *)g_malloc(sizeof(funnel_menu_t));
+ funnel_menu_t* m = g_new(funnel_menu_t, 1);
m->name = g_strdup(name);
m->group = group;
m->callback = callback;
@@ -114,7 +114,7 @@ void funnel_register_menu(const char *name,
void funnel_deregister_menus(funnel_menu_callback callback)
{
- funnel_menu_t* m = (funnel_menu_t *)g_malloc0(sizeof(funnel_menu_t));
+ funnel_menu_t* m = g_new0(funnel_menu_t, 1);
m->callback = callback;
funnel_remove_menu(&registered_menus, m);
diff --git a/epan/packet.c b/epan/packet.c
index 2085c770ed..e14fce8ec1 100644
--- a/epan/packet.c
+++ b/epan/packet.c
@@ -1074,7 +1074,7 @@ dissector_add_uint(const char *name, const guint32 pattern, dissector_handle_t h
dissector_add_uint_sanity_check(name, pattern, handle, sub_dissectors);
#endif
- dtbl_entry = (dtbl_entry_t *)g_malloc(sizeof (dtbl_entry_t));
+ dtbl_entry = g_new(dtbl_entry_t, 1);
dtbl_entry->current = handle;
dtbl_entry->initial = dtbl_entry->current;
@@ -1330,7 +1330,7 @@ dissector_change_uint(const char *name, const guint32 pattern, dissector_handle_
if (handle == NULL)
return;
- dtbl_entry = (dtbl_entry_t *)g_malloc(sizeof (dtbl_entry_t));
+ dtbl_entry = g_new(dtbl_entry_t, 1);
dtbl_entry->initial = NULL;
dtbl_entry->current = handle;
@@ -1554,7 +1554,7 @@ dissector_add_string(const char *name, const gchar *pattern,
g_assert_not_reached();
}
- dtbl_entry = (dtbl_entry_t *)g_malloc(sizeof (dtbl_entry_t));
+ dtbl_entry = g_new(dtbl_entry_t, 1);
dtbl_entry->current = handle;
dtbl_entry->initial = dtbl_entry->current;
@@ -1638,7 +1638,7 @@ dissector_change_string(const char *name, const gchar *pattern,
if (handle == NULL)
return;
- dtbl_entry = (dtbl_entry_t *)g_malloc(sizeof (dtbl_entry_t));
+ dtbl_entry = g_new(dtbl_entry_t, 1);
dtbl_entry->initial = NULL;
dtbl_entry->current = handle;
@@ -1800,7 +1800,7 @@ void dissector_add_custom_table_handle(const char *name, void *pattern, dissecto
g_assert(sub_dissectors->type == FT_BYTES);
- dtbl_entry = (dtbl_entry_t *)g_malloc(sizeof (dtbl_entry_t));
+ dtbl_entry = g_new(dtbl_entry_t, 1);
dtbl_entry->current = handle;
dtbl_entry->initial = dtbl_entry->current;
@@ -1858,7 +1858,7 @@ void dissector_add_guid(const char *name, guid_key* guid_val, dissector_handle_t
g_assert_not_reached();
}
- dtbl_entry = (dtbl_entry_t *)g_malloc(sizeof (dtbl_entry_t));
+ dtbl_entry = g_new(dtbl_entry_t, 1);
dtbl_entry->current = handle;
dtbl_entry->initial = dtbl_entry->current;
diff --git a/epan/plugin_if.c b/epan/plugin_if.c
index 821053be6d..1231c533ef 100644
--- a/epan/plugin_if.c
+++ b/epan/plugin_if.c
@@ -72,7 +72,7 @@ extern ext_menu_t * ext_menubar_register_menu(int proto_id, const gchar * menula
/* For now, a protocol may only register one main menu */
g_assert(g_list_find(menubar_menunames, name) == NULL);
- entry = (ext_menubar_t *)g_malloc0(sizeof(ext_menubar_t));
+ entry = g_new0(ext_menubar_t, 1);
entry->type = EXT_MENUBAR_MENU;
entry->proto = proto_id;
entry->is_plugin = is_plugin;
@@ -117,7 +117,7 @@ extern ext_menu_t * ext_menubar_add_submenu(ext_menu_t * parent, const gchar *me
parent->submenu_cnt++;
/* Create submenu entry */
- entry = (ext_menubar_t *)g_malloc0(sizeof(ext_menubar_t));
+ entry = g_new0(ext_menubar_t, 1);
entry->type = EXT_MENUBAR_MENU;
entry->parent = parent;
/* Just a convenience */
@@ -147,7 +147,7 @@ static void ext_menubar_add_generic_entry (
parent->item_cnt++;
/* Create menu entry */
- entry = (ext_menubar_t*)g_malloc0(sizeof(ext_menubar_t));
+ entry = g_new0(ext_menubar_t, 1);
entry->type = type;
/* Create unique name, which is used by GTK to provide the menu */
entry->name = g_strdup_printf("%sI%02d", parent->name, parent->item_cnt);
diff --git a/epan/prefs.c b/epan/prefs.c
index 68a535411f..8d564dcdf3 100644
--- a/epan/prefs.c
+++ b/epan/prefs.c
@@ -3728,7 +3728,7 @@ prefs_get_string_list(const gchar *str)
GList *sl = NULL;
/* Allocate a buffer for the first string. */
- slstr = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
+ slstr = g_new(gchar, COL_MAX_LEN);
j = 0;
for (;;) {
@@ -3785,7 +3785,7 @@ prefs_get_string_list(const gchar *str)
slstr[j] = '\0';
if (j > 0) {
sl = g_list_append(sl, slstr);
- slstr = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
+ slstr = g_new(gchar, COL_MAX_LEN);
}
/* ...and the beginning of a new string. */
diff --git a/epan/print_stream.c b/epan/print_stream.c
index 3c3cb74092..a694216171 100644
--- a/epan/print_stream.c
+++ b/epan/print_stream.c
@@ -664,7 +664,7 @@ print_stream_text_alloc(gboolean to_file, FILE *fh)
output->color_type = COLOR_NONE;
}
- stream = (print_stream_t *)g_malloc(sizeof (print_stream_t));
+ stream = g_new(print_stream_t, 1);
stream->ops = &print_text_ops;
stream->data = output;
@@ -834,7 +834,7 @@ print_stream_ps_alloc(gboolean to_file, FILE *fh)
output->to_file = to_file;
output->fh = fh;
- stream = (print_stream_t *)g_malloc(sizeof (print_stream_t));
+ stream = g_new(print_stream_t, 1);
stream->ops = &print_ps_ops;
stream->data = output;
diff --git a/epan/proto_data.c b/epan/proto_data.c
index 946a4795cb..5a851fab29 100644
--- a/epan/proto_data.c
+++ b/epan/proto_data.c
@@ -72,7 +72,7 @@ p_add_proto_data(wmem_allocator_t *tmp_scope, struct _packet_info* pinfo, int pr
DISSECTOR_ASSERT(!"invalid wmem scope");
}
- p1 = (proto_data_t *)wmem_alloc(scope, sizeof(proto_data_t));
+ p1 = wmem_new(scope, proto_data_t);
p1->proto = proto;
p1->key = key;
diff --git a/epan/srt_table.c b/epan/srt_table.c
index bb528b5e33..56ce01c149 100644
--- a/epan/srt_table.c
+++ b/epan/srt_table.c
@@ -210,7 +210,7 @@ init_srt_table(const char *name, const char *short_name, GArray *srt_array, int
table->short_name = short_name;
table->proc_column_name = proc_column_name;
table->num_procs=num_procs;
- table->procedures=(srt_procedure_t *)g_malloc(sizeof(srt_procedure_t)*num_procs);
+ table->procedures=g_new(srt_procedure_t, num_procs);
for(i=0;i<num_procs;i++){
time_stat_init(&table->procedures[i].stats);
table->procedures[i].proc_index = 0;
diff --git a/epan/stat_tap_ui.c b/epan/stat_tap_ui.c
index e8020106e1..f9e5100621 100644
--- a/epan/stat_tap_ui.c
+++ b/epan/stat_tap_ui.c
@@ -97,7 +97,7 @@ process_stat_cmd_arg(const char *optstr)
for (entry = wmem_list_tail(stat_cmd_arg_list); entry; entry = wmem_list_frame_prev(entry)) {
sca = (stat_cmd_arg*)wmem_list_frame_data(entry);
if (!strncmp(sca->cmd, stat_command, strlen(sca->cmd))) {
- tr=(stat_requested *)g_malloc(sizeof (stat_requested));
+ tr=g_new(stat_requested, 1);
tr->sca = sca;
tr->arg = stat_command;
stats_requested = g_slist_append(stats_requested, tr);
diff --git a/epan/stats_tree.c b/epan/stats_tree.c
index 18499582c9..be83cf36ba 100644
--- a/epan/stats_tree.c
+++ b/epan/stats_tree.c
@@ -176,7 +176,7 @@ reset_stat_node(stat_node *node)
node->bh = bucket->next;
g_free(bucket);
}
- node->bh = (burst_bucket*)g_malloc0(sizeof(burst_bucket));
+ node->bh = g_new0(burst_bucket, 1);
node->bt = node->bh;
node->bcount = 0;
node->max_burst = 0;
@@ -231,7 +231,7 @@ stats_tree_reinit(void *p)
}
st->root.st_flags = 0;
- st->root.bh = (burst_bucket*)g_malloc0(sizeof(burst_bucket));
+ st->root.bh = g_new0(burst_bucket, 1);
st->root.bt = st->root.bh;
st->root.bcount = 0;
st->root.max_burst = 0;
@@ -325,7 +325,7 @@ stats_tree_register_plugin(const char *tapname, const char *abbr, const char *na
extern stats_tree*
stats_tree_new(stats_tree_cfg *cfg, tree_pres *pr, const char *filter)
{
- stats_tree *st = (stats_tree *)g_malloc0(sizeof(stats_tree));
+ stats_tree *st = g_new0(stats_tree, 1);
st->cfg = cfg;
st->pr = pr;
@@ -349,7 +349,7 @@ stats_tree_new(stats_tree_cfg *cfg, tree_pres *pr, const char *filter)
break;
}
- st->root.bh = (burst_bucket*)g_malloc0(sizeof(burst_bucket));
+ st->root.bh = g_new0(burst_bucket, 1);
st->root.bt = st->root.bh;
st->root.burst_time = -1.0;
@@ -462,7 +462,7 @@ new_stat_node(stats_tree *st, const gchar *name, int parent_id, stat_node_dataty
gboolean with_hash, gboolean as_parent_node)
{
- stat_node *node = (stat_node *)g_malloc0(sizeof(stat_node));
+ stat_node *node = g_new0(stat_node, 1);
stat_node *last_chld = NULL;
node->datatype = datatype;
@@ -479,7 +479,7 @@ new_stat_node(stats_tree *st, const gchar *name, int parent_id, stat_node_dataty
}
node->st_flags = parent_id?0:ST_FLG_ROOTCHILD;
- node->bh = (burst_bucket*)g_malloc0(sizeof(burst_bucket));
+ node->bh = g_new0(burst_bucket, 1);
node->bt = node->bh;
node->burst_time = -1.0;
@@ -572,7 +572,7 @@ update_burst_calc(stat_node *node, gint value)
burstwin = prefs.st_burst_windowlen/prefs.st_burst_resolution;
if (current_bucket>node->bt->bucket_no) {
/* Must add a new bucket at the burst list tail */
- bn = (burst_bucket*)g_malloc0(sizeof(burst_bucket));
+ bn = g_new0(burst_bucket, 1);
bn->count = value;
bn->bucket_no = current_bucket;
bn->start_time = node->st->now;
@@ -595,7 +595,7 @@ update_burst_calc(stat_node *node, gint value)
/* Packet must be added at head of burst list - check if not too old */
if ((current_bucket+burstwin)>node->bt->bucket_no) {
/* packet still within the window */
- bn = (burst_bucket*)g_malloc0(sizeof(burst_bucket));
+ bn = g_new0(burst_bucket, 1);
bn->count = value;
bn->bucket_no = current_bucket;
bn->start_time = node->st->now;
@@ -622,7 +622,7 @@ update_burst_calc(stat_node *node, gint value)
}
else {
/* must add a new bucket after bn. */
- bn = (burst_bucket*)g_malloc0(sizeof(burst_bucket));
+ bn = g_new0(burst_bucket, 1);
bn->count = value;
bn->bucket_no = current_bucket;
bn->start_time = node->st->now;
@@ -805,7 +805,7 @@ get_range(char *rngstr)
return NULL;
}
- rng = (range_pair_t *)g_malloc(sizeof(range_pair_t));
+ rng = g_new(range_pair_t, 1);
if (split[1] == NULL) {
/* means we have a non empty string with no delimiter
diff --git a/epan/tap.c b/epan/tap.c
index e2997a6cd4..bb1145b999 100644
--- a/epan/tap.c
+++ b/epan/tap.c
@@ -172,7 +172,7 @@ register_tap(const char *name)
tdl = tdl_prev;
}
- td=(tap_dissector_t *)g_malloc(sizeof(tap_dissector_t));
+ td=g_new(tap_dissector_t, 1);
td->next=NULL;
td->name = g_strdup(name);
@@ -527,7 +527,7 @@ register_tap_listener(const char *tapname, void *tapdata, const char *fstring,
return error_string;
}
- tl=(tap_listener_t *)g_malloc0(sizeof(tap_listener_t));
+ tl=g_new0(tap_listener_t, 1);
tl->needs_redraw=TRUE;
tl->failed=FALSE;
tl->flags=flags;
diff --git a/epan/tvbparse.c b/epan/tvbparse.c
index 91c7205baf..ade4624558 100644
--- a/epan/tvbparse.c
+++ b/epan/tvbparse.c
@@ -843,7 +843,7 @@ static int cond_handle(tvbparse_t* tt, const int offset, const tvbparse_wanted_t
}
tvbparse_wanted_t* tvbparse_handle(tvbparse_wanted_t** handle) {
- tvbparse_wanted_t* w = (tvbparse_wanted_t *)g_malloc0(sizeof(tvbparse_wanted_t));
+ tvbparse_wanted_t* w = g_new0(tvbparse_wanted_t, 1);
w->condition = cond_handle;
w->control.handle = handle;
@@ -864,7 +864,7 @@ tvbparse_wanted_t* tvbparse_end_of_buffer(const int id,
const void* data,
tvbparse_action_t before_cb,
tvbparse_action_t after_cb) {
- tvbparse_wanted_t* w = (tvbparse_wanted_t *)g_malloc0(sizeof(tvbparse_wanted_t));
+ tvbparse_wanted_t* w = g_new0(tvbparse_wanted_t, 1);
w->id = id;
w->condition = cond_end;
diff --git a/epan/uat.c b/epan/uat.c
index ab3b0e99e7..e30518b88d 100644
--- a/epan/uat.c
+++ b/epan/uat.c
@@ -54,7 +54,7 @@ uat_t* uat_new(const char* name,
uat_reset_cb_t reset_cb,
uat_field_t* flds_array) {
/* Create new uat */
- uat_t* uat = (uat_t *)g_malloc(sizeof(uat_t));
+ uat_t* uat = g_new(uat_t, 1);
guint i;
/* Add to global array of uats */
@@ -96,7 +96,7 @@ uat_t* uat_new(const char* name,
uat->flags = flags;
for (i=0;flds_array[i].title;i++) {
- fld_data_t* f = (fld_data_t *)g_malloc(sizeof(fld_data_t));
+ fld_data_t* f = g_new(fld_data_t, 1);
f->colnum = i+1;
f->rep = NULL;
diff --git a/epan/wslua/init_wslua.c b/epan/wslua/init_wslua.c
index bb131d6f65..da0a6a5b68 100644
--- a/epan/wslua/init_wslua.c
+++ b/epan/wslua/init_wslua.c
@@ -417,7 +417,7 @@ static void wslua_add_plugin(const gchar *name, const gchar *version, const gcha
wslua_plugin *new_plug, *lua_plug;
lua_plug = wslua_plugin_list;
- new_plug = (wslua_plugin *)g_malloc(sizeof(wslua_plugin));
+ new_plug = g_new(wslua_plugin, 1);
if (!lua_plug) { /* the list is empty */
wslua_plugin_list = new_plug;
diff --git a/epan/wslua/wslua_file_common.c b/epan/wslua/wslua_file_common.c
index 7c0421a751..2854a2de1b 100644
--- a/epan/wslua/wslua_file_common.c
+++ b/epan/wslua/wslua_file_common.c
@@ -30,7 +30,7 @@
/* create and set the wtap->priv private data for the file instance */
void create_wth_priv(lua_State* L, wtap *wth) {
- file_priv_t *priv = (file_priv_t*)g_malloc(sizeof(file_priv_t));
+ file_priv_t *priv = g_new(file_priv_t, 1);
if (wth->priv != NULL) {
g_free(priv);
@@ -107,7 +107,7 @@ void remove_wth_priv(lua_State* L, wtap *wth) {
/* create and set the wtap_dumper->priv private data for the file instance */
void create_wdh_priv(lua_State* L, wtap_dumper *wdh) {
- file_priv_t *priv = (file_priv_t*)g_malloc(sizeof(file_priv_t));
+ file_priv_t *priv = g_new(file_priv_t, 1);
if (wdh->priv != NULL) {
g_free(priv);
diff --git a/epan/wslua/wslua_file_handler.c b/epan/wslua/wslua_file_handler.c
index 004f8725a6..627c25edc1 100644
--- a/epan/wslua/wslua_file_handler.c
+++ b/epan/wslua/wslua_file_handler.c
@@ -741,7 +741,7 @@ WSLUA_FUNCTION wslua_register_filehandler(lua_State* L) {
fh->finfo.additional_file_extensions = extra_extensions;
}
fh->finfo.can_write_encap = wslua_dummy_can_write_encap;
- fh->finfo.wslua_info = (wtap_wslua_file_info_t*) g_malloc0(sizeof(wtap_wslua_file_info_t));
+ fh->finfo.wslua_info = g_new0(wtap_wslua_file_info_t, 1);
fh->finfo.wslua_info->wslua_can_write_encap = wslua_filehandler_can_write_encap;
fh->finfo.wslua_info->wslua_data = (void*)(fh);
fh->finfo.dump_open = wslua_filehandler_dump_open;
diff --git a/epan/wslua/wslua_gui.c b/epan/wslua/wslua_gui.c
index 5dd45f753e..984848d79c 100644
--- a/epan/wslua/wslua_gui.c
+++ b/epan/wslua/wslua_gui.c
@@ -98,7 +98,7 @@ WSLUA_FUNCTION wslua_register_menu(lua_State* L) { /* Register a menu item in o
return 0;
}
- md = (struct _lua_menu_data *)g_malloc(sizeof(struct _lua_menu_data));
+ md = g_new(struct _lua_menu_data, 1);
md->L = L;
lua_pushvalue(L, 2);
@@ -277,7 +277,7 @@ WSLUA_FUNCTION wslua_new_dialog(lua_State* L) { /*
}
- dcbd = (struct _dlg_cb_data *)g_malloc(sizeof(struct _dlg_cb_data));
+ dcbd = g_new(struct _dlg_cb_data, 1);
dcbd->L = L;
lua_remove(L,1);
@@ -565,11 +565,11 @@ WSLUA_CONSTRUCTOR TextWindow_new(lua_State* L) { /*
}
title = luaL_optstring(L,WSLUA_OPTARG_TextWindow_new_TITLE, "Untitled Window");
- tw = (struct _wslua_tw *)g_malloc(sizeof(struct _wslua_tw));
+ tw = g_new(struct _wslua_tw, 1);
tw->expired = FALSE;
tw->ws_tw = ops->new_text_window(title);
- default_cbd = (struct _close_cb_data *)g_malloc(sizeof(struct _close_cb_data));
+ default_cbd = g_new(struct _close_cb_data, 1);
default_cbd->L = NULL;
default_cbd->func_ref = 0;
@@ -602,7 +602,7 @@ WSLUA_METHOD TextWindow_set_atclose(lua_State* L) { /* Set the function that wil
return 0;
}
- cbd = (struct _close_cb_data *)g_malloc(sizeof(struct _close_cb_data));
+ cbd = g_new(struct _close_cb_data, 1);
cbd->L = L;
cbd->func_ref = luaL_ref(L, LUA_REGISTRYINDEX);
@@ -804,8 +804,8 @@ WSLUA_METHOD TextWindow_add_button(lua_State* L) {
lua_settop(L,3);
if (ops->add_button) {
- fbt = (funnel_bt_t *)g_malloc(sizeof(funnel_bt_t));
- cbd = (wslua_bt_cb_t *)g_malloc(sizeof(wslua_bt_cb_t));
+ fbt = g_new(funnel_bt_t, 1);
+ cbd = g_new(wslua_bt_cb_t, 1);
fbt->tw = tw->ws_tw;
fbt->func = wslua_button_callback;
diff --git a/epan/wslua/wslua_pref.c b/epan/wslua/wslua_pref.c
index 6c685c07a9..550633fc0c 100644
--- a/epan/wslua/wslua_pref.c
+++ b/epan/wslua/wslua_pref.c
@@ -87,7 +87,7 @@ static int new_pref(lua_State* L, pref_type_t type) {
const gchar* label = luaL_optstring(L,1,NULL);
const gchar* descr = luaL_optstring(L,3,"");
- Pref pref = (wslua_pref_t *)g_malloc0(sizeof(wslua_pref_t));
+ Pref pref = g_new0(wslua_pref_t, 1);
pref->label = g_strdup(label);
pref->desc = g_strdup(descr);
pref->type = type;
diff --git a/epan/wslua/wslua_proto.c b/epan/wslua/wslua_proto.c
index 0c1e806dcd..e857b2b4ca 100644
--- a/epan/wslua/wslua_proto.c
+++ b/epan/wslua/wslua_proto.c
@@ -109,7 +109,7 @@ WSLUA_CONSTRUCTOR Proto_new(lua_State* L) { /* Creates a new <<lua_class_Proto,`
return 0;
}
- proto = (wslua_proto_t *)g_malloc(sizeof(wslua_proto_t));
+ proto = g_new(wslua_proto_t, 1);
proto->name = hiname;
proto->loname = loname;
diff --git a/epan/wslua/wslua_proto_field.c b/epan/wslua/wslua_proto_field.c
index 41e5066c66..e3f63273df 100644
--- a/epan/wslua/wslua_proto_field.c
+++ b/epan/wslua/wslua_proto_field.c
@@ -411,7 +411,7 @@ static true_false_string* true_false_string_from_table(lua_State* L, int idx) {
lua_pop(L, 1);
}
- tfs = (true_false_string *) g_malloc(sizeof(true_false_string));
+ tfs = g_new(true_false_string, 1);
tfs->true_string = true_string;
tfs->false_string = false_string;
@@ -428,7 +428,7 @@ static unit_name_string* unit_name_string_from_table(lua_State* L, int idx) {
return NULL;
}
- units = (unit_name_string *) g_malloc0(sizeof(unit_name_string));
+ units = g_new0(unit_name_string, 1);
lua_pushnil(L);
diff --git a/epan/wslua/wslua_tree.c b/epan/wslua/wslua_tree.c
index 960973d492..c7474b6d70 100644
--- a/epan/wslua/wslua_tree.c
+++ b/epan/wslua/wslua_tree.c
@@ -28,7 +28,7 @@ static GPtrArray* outstanding_TreeItem = NULL;
/* pushing a TreeItem with a NULL item or subtree is completely valid for this function */
TreeItem push_TreeItem(lua_State *L, proto_tree *tree, proto_item *item) {
- TreeItem ti = (struct _wslua_treeitem *)g_malloc(sizeof(struct _wslua_treeitem));
+ TreeItem ti = g_new(struct _wslua_treeitem, 1);
ti->tree = tree;
ti->item = item;
@@ -103,7 +103,7 @@ try_add_packet_field(lua_State *L, TreeItem tree_item, TvbRange tvbr, const int
case FT_RELATIVE_TIME:
{
/* nstime_t will be g_free'd by Lua */
- nstime_t *nstime = (nstime_t *) g_malloc0(sizeof(nstime_t));
+ nstime_t *nstime = g_new0(nstime_t, 1);
item = proto_tree_add_time_item(tree_item->tree, hfid, tvbr->tvb->ws_tvb,
tvbr->offset, tvbr->len, encoding,
nstime, &endoff, &err);
diff --git a/epan/wslua/wslua_util.c b/epan/wslua/wslua_util.c
index 187a7e1721..dda34edec2 100644
--- a/epan/wslua/wslua_util.c
+++ b/epan/wslua/wslua_util.c
@@ -512,7 +512,7 @@ WSLUA_FUNCTION wslua_register_stat_cmd_arg(lua_State* L) {
#define WSLUA_ARG_register_stat_cmd_arg_ARGUMENT 1 /* The name of the option argument. */
#define WSLUA_OPTARG_register_stat_cmd_arg_ACTION 2 /* The function to be called when the command is invoked. */
const char* arg = luaL_checkstring(L,WSLUA_ARG_register_stat_cmd_arg_ARGUMENT);
- statcmd_t* sc = (statcmd_t *)g_malloc0(sizeof(statcmd_t)); /* XXX leaked */
+ statcmd_t* sc = g_new0(statcmd_t, 1); /* XXX leaked */
stat_tap_ui ui_info;
sc->L = L;