Browse Source

cocci: allow xcalloc(1, size)

Allocating a pre-cleared single element is quite common and it is
misleading to use CALLOC_ARRAY(); these allocations that would be
affected without this change are not allocating an array.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Junio C Hamano 4 years ago
parent
commit
1c57cc70ec
  1. 2
      contrib/coccinelle/array.cocci

2
contrib/coccinelle/array.cocci

@ -92,7 +92,7 @@ expression n; @@ -92,7 +92,7 @@ expression n;
@@
type T;
T *ptr;
expression n;
expression n != 1;
@@
- ptr = xcalloc(n, \( sizeof(*ptr) \| sizeof(T) \) )
+ CALLOC_ARRAY(ptr, n)

Loading…
Cancel
Save