mirror of https://github.com/oxen-io/lokinet
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
294 B
C
20 lines
294 B
C
6 years ago
|
#include "swap.h"
|
||
|
|
||
|
void swap(void *x,void *y,int bytes,int mask)
|
||
|
{
|
||
|
int i;
|
||
|
char xi, yi, c, t;
|
||
|
|
||
|
c = mask;
|
||
|
|
||
|
for (i = 0;i < bytes;++i) {
|
||
|
xi = i[(char *) x];
|
||
|
yi = i[(char *) y];
|
||
|
t = c & (xi ^ yi);
|
||
|
xi ^= t;
|
||
|
yi ^= t;
|
||
|
i[(char *) x] = xi;
|
||
|
i[(char *) y] = yi;
|
||
|
}
|
||
|
}
|