From: Heng Li Date: Fri, 23 Sep 2011 04:04:11 +0000 (-0400) Subject: added ks_resize() X-Git-Tag: spawn-final~87 X-Git-Url: http://git.kaiwu.me/postgresql/log/contrib/postgres_fdw/static/gitweb.js?a=commitdiff_plain;h=e1dfef7793fb5ba93e87c9d05422d1f29560b0d1;p=klib.git added ks_resize() --- 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) {