mirror of
https://github.com/git/git
synced 2024-10-30 23:05:50 +00:00
45ccef87b3
Add a semantic patch for converting certain calls of memcpy(3) to COPY_ARRAY() and apply that transformation to the code base. The result is shorter and safer code. For now only consider calls where source and destination have the same type, or in other words: easy cases. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
26 lines
326 B
Text
26 lines
326 B
Text
@@
|
|
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);
|