mirror of
https://github.com/git/git.git
synced 2024-11-01 14:57:52 +01:00
3f64699ffd
Add a semantic patch for using ALLOC_ARRAY to allocate arrays and apply the transformation on the current source tree. The macro checks for multiplication overflow and infers the element size automatically; the result is shorter and safer code. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
42 lines
513 B
Text
42 lines
513 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);
|
|
|
|
@@
|
|
type T;
|
|
T *ptr;
|
|
expression n;
|
|
@@
|
|
- ptr = xmalloc(n * sizeof(*ptr));
|
|
+ ALLOC_ARRAY(ptr, n);
|
|
|
|
@@
|
|
type T;
|
|
T *ptr;
|
|
expression n;
|
|
@@
|
|
- ptr = xmalloc(n * sizeof(T));
|
|
+ ALLOC_ARRAY(ptr, n);
|