+char* allocprintf(const char*format, ...)
+{
+ va_list arglist1;
+ va_start(arglist1, format);
+ char dummy;
+ int l = vsnprintf(&dummy, 1, format, arglist1);
+ va_end(arglist1);
+
+ va_list arglist2;
+ va_start(arglist2, format);
+ char*buf = malloc(l+1);
+ vsnprintf(buf, l+1, format, arglist2);
+ va_end(arglist2);
+ return buf;
+}