Skip to content

Commit 1c57cc7

Browse files
committed
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 <[email protected]>
1 parent ca56dad commit 1c57cc7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

contrib/coccinelle/array.cocci

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ expression n;
9292
@@
9393
type T;
9494
T *ptr;
95-
expression n;
95+
expression n != 1;
9696
@@
9797
- ptr = xcalloc(n, \( sizeof(*ptr) \| sizeof(T) \) )
9898
+ CALLOC_ARRAY(ptr, n)

0 commit comments

Comments
 (0)