1@@
2expression dst, src, n, E;
3@@
4 memcpy(dst, src, n * sizeof(
5- E[...]
6+ *(E)
7 ))
8
9@@
10type T;
11T *ptr;
12T[] arr;
13expression E, n;
14@@
15(
16 memcpy(ptr, E,
17- n * sizeof(*(ptr))
18+ n * sizeof(T)
19 )
20|
21 memcpy(arr, E,
22- n * sizeof(*(arr))
23+ n * sizeof(T)
24 )
25|
26 memcpy(E, ptr,
27- n * sizeof(*(ptr))
28+ n * sizeof(T)
29 )
30|
31 memcpy(E, arr,
32- n * sizeof(*(arr))
33+ n * sizeof(T)
34 )
35)
36
37@@
38type T;
39T *dst_ptr;
40T *src_ptr;
41T[] dst_arr;
42T[] src_arr;
43expression n;
44@@
45(
46- memcpy(dst_ptr, src_ptr, (n) * sizeof(T))
47+ COPY_ARRAY(dst_ptr, src_ptr, n)
48|
49- memcpy(dst_ptr, src_arr, (n) * sizeof(T))
50+ COPY_ARRAY(dst_ptr, src_arr, n)
51|
52- memcpy(dst_arr, src_ptr, (n) * sizeof(T))
53+ COPY_ARRAY(dst_arr, src_ptr, n)
54|
55- memcpy(dst_arr, src_arr, (n) * sizeof(T))
56+ COPY_ARRAY(dst_arr, src_arr, n)
57)
58
59@@
60type T;
61T *dst;
62T *src;
63expression n;
64@@
65(
66- memmove(dst, src, (n) * sizeof(*dst));
67+ MOVE_ARRAY(dst, src, n);
68|
69- memmove(dst, src, (n) * sizeof(*src));
70+ MOVE_ARRAY(dst, src, n);
71|
72- memmove(dst, src, (n) * sizeof(T));
73+ MOVE_ARRAY(dst, src, n);
74)
75
76@@
77type T;
78T *ptr;
79expression n;
80@@
81- ptr = xmalloc((n) * sizeof(*ptr));
82+ ALLOC_ARRAY(ptr, n);
83
84@@
85type T;
86T *ptr;
87expression n;
88@@
89- ptr = xmalloc((n) * sizeof(T));
90+ ALLOC_ARRAY(ptr, n);