Vector 0.0.2
Loading...
Searching...
No Matches
memswap.c
1#include "memswap.h"
2
3void memswap(char *restrict a, char *restrict b, const size_t size)
4{
5 for (size_t i = 0; i < size / sizeof(size_t); ++i)
6 {
7 *(size_t*)a ^= *(size_t*)b;
8 *(size_t*)b ^= *(size_t*)a;
9 *(size_t*)a ^= *(size_t*)b;
10 a += sizeof(size_t);
11 b += sizeof(size_t);
12 }
13 for (size_t i = 0; i < size % sizeof(size_t); ++i, ++a, ++b)
14 {
15 *a ^= *b;
16 *b ^= *a;
17 *a ^= *b;
18 }
19}