diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2018-11-24 08:13:23 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2018-11-24 08:13:23 +0000 |
commit | 1af5a42e566da1e615abae7868ae7a10260ce0b8 (patch) | |
tree | 7caa98782dca3431b28f268a01ee7b2dcd23226d /src | |
parent | 661329653329949929b043f5fc45821aa314face (diff) | |
download | skalibs-1af5a42e566da1e615abae7868ae7a10260ce0b8.tar.xz |
bugfix: rounding error in stralloc_reverse_blocks
Diffstat (limited to 'src')
-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) ; } } |