*buf->dptr = '\0';
}
+ssize_t buffer_addvf(buffer_t *buf, const char *fmt, va_list args)
+{
+ ssize_t len;
+ va_list ap;
+
+ va_copy(ap, args);
+ buffer_ensure(buf, BUFSIZ);
+
+ len = vsnprintf(buf->data + buf->len, buf->size - buf->len, fmt, args);
+ if (len < 0) {
+ len = 0;
+ }
+ if (len >= buf->size - buf->len) {
+ buffer_ensure(buf, len);
+ vsnprintf(buf->data + buf->len, buf->size - buf->len, fmt, ap);
+ }
+ buf->len += len;
+ buf->data[buf->len] = '\0';
+
+ return len;
+}
+
+ssize_t buffer_addf(buffer_t *buf, const char *fmt, ...) {
+ ssize_t res;
+ va_list args;
+ va_start(args, fmt);
+ res = buffer_addvf(buf, fmt, args);
+ va_end(args);
+ return res;
+}
}
}
+ssize_t buffer_addvf(buffer_t *buf, const char *fmt, va_list)
+ __attribute__((format(printf, 2, 0)));
+
+ssize_t buffer_addf(buffer_t *buf, const char *fmt, ...)
+ __attribute__((format(printf, 2, 3)));
+
/****** LEGACY BUFFERS *******/