blob: 8f2af303045eca91fb1bb47f02d024db8eda59fe [file] [edit]
#include "compat/src_compat.h"
#include <stdio.h>
#include <stdlib.h>
int vasprintf(char **strp, const char *fmt, va_list ap) {
int size = vsnprintf(NULL, 0, fmt, ap);
if (size < 0) {
return -1;
}
*strp = (char *)malloc(size + 1);
if (!*strp) {
return -1;
}
return vsnprintf(*strp, size + 1, fmt, ap);
}