diff options
-rw-r--r-- | strbuf.c | 7 | ||||
-rw-r--r-- | trace.c | 4 |
2 files changed, 6 insertions, 5 deletions
@@ -111,12 +111,13 @@ void strbuf_addf(struct strbuf *sb, const char *fmt, ...) int len; va_list ap; + if (!strbuf_avail(sb)) + strbuf_grow(sb, 64); va_start(ap, fmt); len = vsnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap); va_end(ap); - if (len < 0) { - len = 0; - } + if (len < 0) + die("your vsnprintf is broken"); if (len > strbuf_avail(sb)) { strbuf_grow(sb, len); va_start(ap, fmt); @@ -72,7 +72,7 @@ void trace_printf(const char *fmt, ...) if (!fd) return; - strbuf_init(&buf, 0); + strbuf_init(&buf, 64); va_start(ap, fmt); len = vsnprintf(buf.buf, strbuf_avail(&buf), fmt, ap); va_end(ap); @@ -103,7 +103,7 @@ void trace_argv_printf(const char **argv, int count, const char *fmt, ...) if (!fd) return; - strbuf_init(&buf, 0); + strbuf_init(&buf, 64); va_start(ap, fmt); len = vsnprintf(buf.buf, strbuf_avail(&buf), fmt, ap); va_end(ap); |