Wireshark-commits: [Wireshark-commits] master 3b47a55: Replace instances of wmem_alloc with wmem_ne

From: Wireshark code review <code-review-do-not-reply@xxxxxxxxxxxxx>
Date: Sat, 8 Aug 2020 09:54:41 +0000
URL: https://code.wireshark.org/review/gitweb?p=wireshark.git;a=commit;h=3b47a55b0daeddb4edee6390387b0dfca1135be3
Submitter: "Anders Broman <a.broman58@xxxxxxxxx>"
Changed: branch: master
Repository: wireshark

Commits:

3b47a55 by Moshe Kaplan (me@xxxxxxxxxxxxxxx):

    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@xxxxxxxxx>
    Tested-by: Petri Dish Buildbot
    Reviewed-by: Anders Broman <a.broman58@xxxxxxxxx>
    

Actions performed:

    from  191e1f6   Kerberos: make tfs change in template rather than directly.
     add  3b47a55   Replace instances of wmem_alloc with wmem_new


Summary of changes:
 epan/exported_pdu.c                   |  2 +-
 epan/proto.c                          |  2 +-
 epan/tvbparse.c                       | 20 ++++++++++----------
 plugins/epan/unistim/packet-unistim.c |  2 +-
 4 files changed, 13 insertions(+), 13 deletions(-)