apply: use SWAP macro

Use the exported macro SWAP instead of the file-scoped macro swap and remove the latter's definition. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Jan 28, 2017 at 22:40 UTC db101991414f4e14b3763b4843dddcca6b31b40b
1 file changed +7 -16
apply.c
+7 -16
@@ -2187,29 +2187,20 @@ static int parse_chunk(struct apply_state *state, char *buffer, unsigned long si
2187 return offset + hdrsize + patchsize;
2188 }
2189
2190 -#define swap(a,b) myswap((a),(b),sizeof(a))
2191 -
2192 -#define myswap(a, b, size) do { \
2193 - unsigned char mytmp[size]; \
2194 - memcpy(mytmp, &a, size); \
2195 - memcpy(&a, &b, size); \
2196 - memcpy(&b, mytmp, size); \
2197 -} while (0)
2198 -
2190 static void reverse_patches(struct patch *p)
2191 {
2192 for (; p; p = p->next) {
2193 struct fragment *frag = p->fragments;
2194
2204 - swap(p->new_name, p->old_name);
2205 - swap(p->new_mode, p->old_mode);
2206 - swap(p->is_new, p->is_delete);
2207 - swap(p->lines_added, p->lines_deleted);
2208 - swap(p->old_sha1_prefix, p->new_sha1_prefix);
2195 + SWAP(p->new_name, p->old_name);
2196 + SWAP(p->new_mode, p->old_mode);
2197 + SWAP(p->is_new, p->is_delete);
2198 + SWAP(p->lines_added, p->lines_deleted);
2199 + SWAP(p->old_sha1_prefix, p->new_sha1_prefix);
2200
2201 for (; frag; frag = frag->next) {
2211 - swap(frag->newpos, frag->oldpos);
2212 - swap(frag->newlines, frag->oldlines);
2202 + SWAP(frag->newpos, frag->oldpos);
2203 + SWAP(frag->newlines, frag->oldlines);
2204 }
2205 }
2206 }