From e1dfef7793fb5ba93e87c9d05422d1f29560b0d1 Mon Sep 17 00:00:00 2001 From: Heng Li Date: Fri, 23 Sep 2011 00:04:11 -0400 Subject: [PATCH] added ks_resize() --- kstring.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/kstring.h b/kstring.h index 73fcc6b..89a7920 100644 --- a/kstring.h +++ b/kstring.h @@ -67,7 +67,16 @@ extern "C" { #ifdef __cplusplus } #endif - + +static inline void ks_resize(kstring_t *s, size_t size) +{ + if (s->m < size) { + s->m = size; + kroundup32(s->m); + s->s = (char*)realloc(s->s, s->m); + } +} + static inline int kputsn(const char *p, int l, kstring_t *s) { if (s->l + l + 1 >= s->m) { -- 2.47.3