From fd7895d37c2410f81231efdfd8b0640c15887a70 Mon Sep 17 00:00:00 2001 From: Moshe Kaplan Date: Thu, 7 May 2020 08:35:45 -0400 Subject: 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 Tested-by: Petri Dish Buildbot Reviewed-by: Pascal Quantin --- epan/dissectors/packet-tpm20.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'epan/dissectors/packet-tpm20.c') 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; -- cgit v1.2.3