blob: 6a2e4b8e942ebe36e68c5910b11cef3fc4899d39 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
/* ISC license. */
#include <skalibs/bytestr.h>
#include <skalibs/stralloc.h>
void stralloc_reverse_blocks (stralloc *sa, unsigned int size)
{
register unsigned int n = sa->len / (size << 1) ;
register unsigned int i = 0 ;
char tmp[size] ;
for (; i < n ; i++)
{
byte_copy(tmp, size, sa->s + i * size) ;
byte_copy(sa->s + i * size, size, sa->s + (2*n - 1 - i) * size) ;
byte_copy(sa->s + (2*n - 1 - i) * size, size, tmp) ;
}
}
|