blob: 6aebf7c59921a1f25b5714e2444b38529808d830 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#include <stddef.h>
#include "common.h"
#include "counts.h"
/* rotates left */
void rotate(char *base, size_t size, size_t shift)
{
size_t a = shift, b = size - shift;
while (a && b) {
if (a <= b) {
swap(base, base + b, a);
b -= a;
} else {
swap(base, base + a, b);
base += b;
a -= b;
}
}
}
|