Mercurial > hg > nnchat
diff th_string.c @ 282:3dc86d8eb0a9
Added helper functions for easier string manipulation.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 09 Jun 2011 20:48:17 +0300 |
parents | 517c7b22b3c9 |
children | eb74097b73f5 |
line wrap: on
line diff
--- a/th_string.c Thu Jun 09 19:31:13 2011 +0300 +++ b/th_string.c Thu Jun 09 20:48:17 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)