diff options
Diffstat (limited to 'src/libstddjb/stralloc_reverse.c')
-rw-r--r-- | src/libstddjb/stralloc_reverse.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libstddjb/stralloc_reverse.c b/src/libstddjb/stralloc_reverse.c new file mode 100644 index 0000000..9ad29e7 --- /dev/null +++ b/src/libstddjb/stralloc_reverse.c @@ -0,0 +1,15 @@ +/* ISC license. */ + +#include <skalibs/bytestr.h> +#include <skalibs/stralloc.h> + +void stralloc_reverse (stralloc *sa) +{ + register unsigned int i = 0 ; + for (; i < sa->len >> 1 ; i++) + { + char tmp = sa->s[i] ; + sa->s[i] = sa->s[sa->len - 1 - i] ; + sa->s[sa->len - 1 - i] = tmp ; + } +} |