30 #define UTSTRING_VERSION 1.9.6 33 #define _UNUSED_ __attribute__ ((__unused__)) 41 #define oom() exit(-1) 49 #define utstring_reserve(s,amt) \ 51 if (((s)->n - (s)->i) < (size_t)(amt)) { \ 52 (s)->d = (char*)realloc((s)->d, (s)->n + amt); \ 53 if ((s)->d == NULL) oom(); \ 58 #define utstring_init(s) \ 60 (s)->n = 0; (s)->i = 0; (s)->d = NULL; \ 61 utstring_reserve(s,100); \ 65 #define utstring_done(s) \ 67 if ((s)->d != NULL) free((s)->d); \ 71 #define utstring_free(s) \ 77 #define utstring_new(s) \ 79 s = (UT_string*)calloc(sizeof(UT_string),1); \ 84 #define utstring_renew(s) \ 93 #define utstring_clear(s) \ 99 #define utstring_bincpy(s,b,l) \ 101 utstring_reserve((s),(l)+1); \ 102 if (l) memcpy(&(s)->d[(s)->i], b, l); \ 104 (s)->d[(s)->i]='\0'; \ 107 #define utstring_concat(dst,src) \ 109 utstring_reserve((dst),((src)->i)+1); \ 110 if ((src)->i) memcpy(&(dst)->d[(dst)->i], (src)->d, (src)->i); \ 111 (dst)->i += (src)->i; \ 112 (dst)->d[(dst)->i]='\0'; \ 115 #define utstring_len(s) ((unsigned)((s)->i)) 117 #define utstring_body(s) ((s)->d) 128 n = vsnprintf (&s->
d[s->
i], s->
n-s->
i, fmt, cp);
131 if ((n > -1) && (n < (
int)(s->
n-s->
i))) {
static _UNUSED_ void utstring_printf(UT_string *s, const char *fmt,...)
static _UNUSED_ void utstring_printf_va(UT_string *s, const char *fmt, va_list ap)
#define utstring_reserve(s, amt)