summaryrefslogtreecommitdiff
path: root/contrib/coccinelle/array.cocci
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2016-10-03 13:30:33 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2016-10-03 13:30:33 -0700
commitb1f0a856605981363053941b8210f3cc9389607a (patch)
tree9de4bc7cc285925913c219edd4536985cc0cc256 /contrib/coccinelle/array.cocci
parentSync with maint (diff)
parentuse COPY_ARRAY (diff)
downloadtgif-b1f0a856605981363053941b8210f3cc9389607a.tar.xz
Merge branch 'rs/copy-array'
Code cleanup. * rs/copy-array: use COPY_ARRAY add COPY_ARRAY
Diffstat (limited to 'contrib/coccinelle/array.cocci')
-rw-r--r--contrib/coccinelle/array.cocci26
1 files changed, 26 insertions, 0 deletions
diff --git a/contrib/coccinelle/array.cocci b/contrib/coccinelle/array.cocci
new file mode 100644
index 0000000000..2d7f25d99f
--- /dev/null
+++ b/contrib/coccinelle/array.cocci
@@ -0,0 +1,26 @@
+@@
+type T;
+T *dst;
+T *src;
+expression n;
+@@
+- memcpy(dst, src, n * sizeof(*dst));
++ COPY_ARRAY(dst, src, n);
+
+@@
+type T;
+T *dst;
+T *src;
+expression n;
+@@
+- memcpy(dst, src, n * sizeof(*src));
++ COPY_ARRAY(dst, src, n);
+
+@@
+type T;
+T *dst;
+T *src;
+expression n;
+@@
+- memcpy(dst, src, n * sizeof(T));
++ COPY_ARRAY(dst, src, n);