summaryrefslogtreecommitdiff
path: root/source/fitz/printf.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/fitz/printf.c')
-rw-r--r--source/fitz/printf.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/source/fitz/printf.c b/source/fitz/printf.c
index cea13cc1..ddb8f17c 100644
--- a/source/fitz/printf.c
+++ b/source/fitz/printf.c
@@ -462,3 +462,19 @@ fz_snprintf(char *buffer, size_t space, const char *fmt, ...)
return out.n - 1;
}
+
+char *
+fz_asprintf(fz_context *ctx, const char *fmt, ...)
+{
+ int len;
+ char *mem;
+ va_list ap;
+ va_start(ap, fmt);
+ len = fz_vsnprintf(NULL, 0, fmt, ap);
+ va_end(ap);
+ mem = fz_malloc(ctx, len+1);
+ va_start(ap, fmt);
+ fz_vsnprintf(mem, len+1, fmt, ap);
+ va_end(ap);
+ return mem;
+}