]> git.kaiwu.me - klib.git/commitdiff
ks_resize() canonicalises the stored string
authorJohn Marshall <jm18@sanger.ac.uk>
Tue, 23 Jul 2013 15:16:19 +0000 (16:16 +0100)
committerJohn Marshall <jm18@sanger.ac.uk>
Tue, 23 Jul 2013 15:16:19 +0000 (16:16 +0100)
It ensures the string is NUL-terminated, especially in the case that
ks_resize(&kstr,1) has been used on a newly-created kstring_t to ensure
that kstr.s is not NULL.

kstring.h

index da53ba6eb9d9f361cc845d80217b8fe3993b2ddf..4c803b81560daa5d3b549d768c60641f8f14fd46 100644 (file)
--- a/kstring.h
+++ b/kstring.h
@@ -89,6 +89,7 @@ static inline int ks_resize(kstring_t *s, size_t size)
                else
                        return -1;
        }
+       s->s[s->l] = '\0';
        return 0;
 }