aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/epan
diff options
context:
space:
mode:
authorMoshe Kaplan <me@moshekaplan.com>2020-08-07 19:32:16 -0400
committerAnders Broman <a.broman58@gmail.com>2020-08-08 09:54:29 +0000
commit3b47a55b0daeddb4edee6390387b0dfca1135be3 (patch)
tree98fdafc72394091a119250d4d5f0f7dbcde2ea3e /plugins/epan
parent191e1f62d5b27123dae3f4488a5c2e2e799af0a0 (diff)
Replace instances of wmem_alloc with wmem_new
This commit replaces instances of (myobj *)wmem_alloc(wmem_X_scope(), sizeof(myobj)) and replaces them with: wmem_new(wmem_X_scope(), myobj) to improve the readability of Wireshark's code. Replacements were made with the following Python script: import os import re import sys pattern = r'\(([^\s\n]+) ?\*\) ?wmem_alloc(0?)\((wmem_[a-z]+_scope\(\)), sizeof\(\1\)\)' replacewith = r'wmem_new\2(\3, \1)' startdir = sys.argv[1] for root, dirs, files in os.walk(startdir): for fname in files: fpath = os.path.join(root, fname) if not fpath.endswith('.c'): continue with open(fpath, 'r') as fh: fdata = fh.read() output = re.sub(pattern, replacewith, fdata) if fdata != output: print(fpath) with open(fpath, 'w') as fh: fh.write(output) Change-Id: I223cb2fcce336bc99ca21c4a74e4cf758fd00572 Reviewed-on: https://code.wireshark.org/review/38088 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'plugins/epan')
-rw-r--r--plugins/epan/unistim/packet-unistim.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/plugins/epan/unistim/packet-unistim.c b/plugins/epan/unistim/packet-unistim.c
index 4ebad9a158..6c2563142a 100644
--- a/plugins/epan/unistim/packet-unistim.c
+++ b/plugins/epan/unistim/packet-unistim.c
@@ -194,7 +194,7 @@ dissect_unistim(tvbuff_t *tvb,packet_info *pinfo,proto_tree *tree,void *data _U_
proto_tree_add_item(rudpm_tree,hf_unistim_seq_nu,tvb,offset,4,ENC_BIG_ENDIAN);
/* Allocate new mem for queueing */
- uinfo = (unistim_info_t *)wmem_alloc(wmem_packet_scope(), sizeof(unistim_info_t));
+ uinfo = wmem_new(wmem_packet_scope(), unistim_info_t);
/* Clear tap struct */
uinfo->rudp_type = 0;