diff options
author | Moshe Kaplan <me@moshekaplan.com> | 2020-05-07 08:35:45 -0400 |
---|---|---|
committer | Pascal Quantin <pascal@wireshark.org> | 2020-05-07 14:47:54 +0000 |
commit | fd7895d37c2410f81231efdfd8b0640c15887a70 (patch) | |
tree | 899b653a9baa87e6a4f54dd7d7d8e6fd42aa1223 /epan/dissectors/packet-cops.c | |
parent | 87f320ec25a27f06e90f68a200ab7702a5b7c850 (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-cops.c')
-rw-r--r-- | epan/dissectors/packet-cops.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/epan/dissectors/packet-cops.c b/epan/dissectors/packet-cops.c index 0e79d12ed8..c76f4b0d97 100644 --- a/epan/dissectors/packet-cops.c +++ b/epan/dissectors/packet-cops.c @@ -1019,7 +1019,7 @@ dissect_cops_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data conversation = find_or_create_conversation(pinfo); cops_conv_info = (cops_conv_info_t *)conversation_get_proto_data(conversation, proto_cops); if (!cops_conv_info) { - cops_conv_info = (cops_conv_info_t *)wmem_alloc(wmem_file_scope(), sizeof(cops_conv_info_t)); + cops_conv_info = wmem_new(wmem_file_scope(), cops_conv_info_t); cops_conv_info->pdus_tree = wmem_map_new(wmem_file_scope(), g_direct_hash, g_direct_equal); conversation_add_proto_data(conversation, proto_cops, cops_conv_info); |