diff options
Diffstat (limited to 'src/libstddjb')
-rw-r--r-- | src/libstddjb/stralloc_reverse_blocks.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/libstddjb/stralloc_reverse_blocks.c b/src/libstddjb/stralloc_reverse_blocks.c index 86b7fc4..731d635 100644 --- a/src/libstddjb/stralloc_reverse_blocks.c +++ b/src/libstddjb/stralloc_reverse_blocks.c @@ -10,8 +10,9 @@ void stralloc_reverse_blocks (stralloc *sa, size_t size) char tmp[size] ; for (; i < n ; i++) { + size_t k = sa->len - (i + 1) * size ; memcpy(tmp, sa->s + i * size, size) ; - memcpy(sa->s + i * size, sa->s + (2*n - 1 - i) * size, size) ; - memcpy(sa->s + (2*n - 1 - i) * size, tmp, size) ; + memcpy(sa->s + i * size, sa->s + k, size) ; + memcpy(sa->s + k, tmp, size) ; } } |