wireshark/plugins/epan
Moshe Kaplan 3b47a55b0d 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>
2020-08-08 09:54:29 +00:00
..
ethercat Fix the type of arrays of pointers to hf_ values for bitfield routines. 2020-06-19 11:32:26 +00:00
gryphon Fix the type of arrays of pointers to hf_ values for bitfield routines. 2020-06-19 11:32:26 +00:00
irda HTTPS In More Places, update some URLs. 2019-07-27 07:55:36 +00:00
mate Fix compilation with gcc-9. 2020-01-21 04:44:31 +00:00
opcua Fix the type of arrays of pointers to hf_ values for bitfield routines. 2020-06-19 11:32:26 +00:00
pluginifdemo pluginifdemo compilable on Windows 2020-07-24 06:00:48 +00:00
profinet Profinet: Wrong Block Length Dissection Fix 2020-07-16 08:17:55 +00:00
stats_tree HTTPS (almost) everywhere. 2019-07-26 18:44:40 +00:00
transum HTTPS In More Places, update some URLs. 2019-07-27 07:55:36 +00:00
unistim Replace instances of wmem_alloc with wmem_new 2020-08-08 09:54:29 +00:00
wimax WiMax DLMAP: Fix a large loop. 2020-02-13 12:17:09 +00:00
wimaxasncp HTTPS In More Places, update some URLs. 2019-07-27 07:55:36 +00:00
wimaxmacphy HTTPS (almost) everywhere. 2019-07-26 18:44:40 +00:00