diff options
author | René Scharfe <l.s.r@web.de> | 2023-01-02 00:16:48 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-01-09 07:28:36 +0300 |
commit | 6e578410960d9ceb35ec98ad4b6fc711f1a9c85c (patch) | |
tree | eda5b7fabcc2394e6b9b3f021d8e03a0833273fe /contrib | |
parent | d2ec87a684e2f9cd1f0c653620a00d74ad5ee2ce (diff) |
use DUP_ARRAY
Add a semantic patch for replace ALLOC_ARRAY+COPY_ARRAY with DUP_ARRAY
to reduce code duplication and apply its results.
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/coccinelle/array.cocci | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/contrib/coccinelle/array.cocci b/contrib/coccinelle/array.cocci index aa75937950..27a3b479c9 100644 --- a/contrib/coccinelle/array.cocci +++ b/contrib/coccinelle/array.cocci @@ -94,3 +94,10 @@ expression n != 1; @@ - ptr = xcalloc(n, \( sizeof(*ptr) \| sizeof(T) \) ) + CALLOC_ARRAY(ptr, n) + +@@ +expression dst, src, n; +@@ +-ALLOC_ARRAY(dst, n); +-COPY_ARRAY(dst, src, n); ++DUP_ARRAY(dst, src, n); |