aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-tpm20.c
diff options
context:
space:
mode:
authorMoshe Kaplan <me@moshekaplan.com>2020-05-07 08:35:45 -0400
committerPascal Quantin <pascal@wireshark.org>2020-05-07 14:47:54 +0000
commitfd7895d37c2410f81231efdfd8b0640c15887a70 (patch)
tree899b653a9baa87e6a4f54dd7d7d8e6fd42aa1223 /epan/dissectors/packet-tpm20.c
parent87f320ec25a27f06e90f68a200ab7702a5b7c850 (diff)
Replace instances of wmem_alloc with wmem_new
This commit replaces instances of (myobj *)wmem_alloc(wmem_file_scope(), sizeof(myobj)) and replaces them with: wmem_new(wmem_file_scope(), myobj) to improve the readability of Wireshark's code. The replacement locations were identified with grep and replaced with the Python script below. grep command: egrep "wmem_alloc0?\(wmem_file_scope\(\), sizeof\([a-z_]+\)\)" . -R -l python script: import re import sys import fileinput pattern = r'\(([^\s]+) ?\*\) ?wmem_alloc(0?)\((wmem_[a-z]+_scope\(\)), sizeof\(\1\)\)' replacewith = r'wmem_new\2(\3, \1)' fname = sys.argv[1] for line in fileinput.input(fname, inplace=1, mode='rb'): output = re.sub(pattern, replacewith, line) sys.stdout.write(output) Change-Id: Ieac246c104bf01e32cbc6e11e53e81c7f639d870 Reviewed-on: https://code.wireshark.org/review/37158 Petri-Dish: Pascal Quantin <pascal@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Pascal Quantin <pascal@wireshark.org>
Diffstat (limited to 'epan/dissectors/packet-tpm20.c')
-rw-r--r--epan/dissectors/packet-tpm20.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/epan/dissectors/packet-tpm20.c b/epan/dissectors/packet-tpm20.c
index 76424932d1..1c40405add 100644
--- a/epan/dissectors/packet-tpm20.c
+++ b/epan/dissectors/packet-tpm20.c
@@ -1086,7 +1086,7 @@ dissect_tpm20(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
entry = (tpm_entry *)wmem_tree_lookup32(cmd_tree, pinfo->num);
if (entry == NULL) {
- entry = (tpm_entry *)wmem_alloc(wmem_file_scope(), sizeof(tpm_entry));
+ entry = wmem_new(wmem_file_scope(), tpm_entry);
entry->com_pnum = PNUM_UNINIT;
entry->resp_type = PNUM_UNINIT;
entry->command = 0;