diff options
author | René Scharfe <l.s.r@web.de> | 2017-01-28 22:40:06 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-01-30 14:07:52 -0800 |
commit | db101991414f4e14b3763b4843dddcca6b31b40b (patch) | |
tree | 099c444d1fe24c075239d00af6d93ce24249b676 /apply.c | |
parent | 568edcb95a8b86ffd0d267b124896df8ea81307c (diff) | |
download | git-db101991414f4e14b3763b4843dddcca6b31b40b.tar.gz |
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>
Diffstat (limited to 'apply.c')
-rw-r--r-- | apply.c | 23 |
1 files changed, 7 insertions, 16 deletions
@@ -2187,29 +2187,20 @@ static int parse_chunk(struct apply_state *state, char *buffer, unsigned long si return offset + hdrsize + patchsize; } -#define swap(a,b) myswap((a),(b),sizeof(a)) - -#define myswap(a, b, size) do { \ - unsigned char mytmp[size]; \ - memcpy(mytmp, &a, size); \ - memcpy(&a, &b, size); \ - memcpy(&b, mytmp, size); \ -} while (0) - static void reverse_patches(struct patch *p) { for (; p; p = p->next) { struct fragment *frag = p->fragments; - swap(p->new_name, p->old_name); - swap(p->new_mode, p->old_mode); - swap(p->is_new, p->is_delete); - swap(p->lines_added, p->lines_deleted); - swap(p->old_sha1_prefix, p->new_sha1_prefix); + SWAP(p->new_name, p->old_name); + SWAP(p->new_mode, p->old_mode); + SWAP(p->is_new, p->is_delete); + SWAP(p->lines_added, p->lines_deleted); + SWAP(p->old_sha1_prefix, p->new_sha1_prefix); for (; frag; frag = frag->next) { - swap(frag->newpos, frag->oldpos); - swap(frag->newlines, frag->oldlines); + SWAP(frag->newpos, frag->oldpos); + SWAP(frag->newlines, frag->oldlines); } } } |