Mercurial > hg > th-libs
diff th_string.c @ 30:10d2dc143e4b
Add helper functions th_pstr_vprintf() and th_pstr_printf().
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 11 Jun 2011 05:04:39 +0300 |
parents | 04cfdefc3253 |
children | a3ad77382c64 |
line wrap: on
line diff
--- a/th_string.c Sat Jun 11 05:03:58 2011 +0300 +++ b/th_string.c Sat Jun 11 05:04:39 2011 +0300 @@ -96,6 +96,27 @@ } +void th_pstr_vprintf(char **buf, const char *fmt, va_list ap) +{ + char *tmp = th_strdup_vprintf(fmt, ap); + th_free(*buf); + *buf = tmp; +} + + +void th_pstr_printf(char **buf, const char *fmt, ...) +{ + char *tmp; + va_list ap; + + va_start(ap, fmt); + tmp = th_strdup_vprintf(fmt, ap); + va_end(ap); + + th_free(*buf); + *buf = tmp; +} + /* Compare two strings ignoring case [strcasecmp, strncasecmp] */ int th_strcasecmp(const char * str1, const char * str2)