]> git.ipfire.org Git - thirdparty/haproxy.git/commit
CLEANUP: uniformize last argument of malloc/calloc
authorVincent Bernat <vincent@bernat.im>
Sun, 3 Apr 2016 11:48:43 +0000 (13:48 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 3 Apr 2016 12:17:42 +0000 (14:17 +0200)
commit02779b6263a177b1e462e53db6eaf57bcda574bc
treeb7153dd707240b17ebada818e22ee954ceed606c
parent3c2f2f207f9ce64ce506a174cc12e8dc7eeed2a8
CLEANUP: uniformize last argument of malloc/calloc

Instead of repeating the type of the LHS argument (sizeof(struct ...))
in calls to malloc/calloc, we directly use the pointer
name (sizeof(*...)). The following Coccinelle patch was used:

@@
type T;
T *x;
@@

  x = malloc(
- sizeof(T)
+ sizeof(*x)
  )

@@
type T;
T *x;
@@

  x = calloc(1,
- sizeof(T)
+ sizeof(*x)
  )

When the LHS is not just a variable name, no change is made. Moreover,
the following patch was used to ensure that "1" is consistently used as
a first argument of calloc, not the last one:

@@
@@

  calloc(
+ 1,
  ...
- ,1
  )
18 files changed:
src/51d.c
src/acl.c
src/cfgparse.c
src/compression.c
src/dns.c
src/dumpstats.c
src/flt_http_comp.c
src/log.c
src/namespace.c
src/peers.c
src/proto_http.c
src/proto_tcp.c
src/proxy.c
src/regex.c
src/sample.c
src/server.c
src/ssl_sock.c
src/uri_auth.c