int vasprintf(char** strp, const char* fmt, va_list ap) {
va_list ap2;
va_copy(ap2, ap);
char tmp[1];
int size = vsnprintf(tmp, 1, fmt, ap2);
if (size <= 0) return size;
va_end(ap2);
size += 1;
*strp = (char*)malloc(size * sizeof(char));
return vsnprintf(*strp, size, fmt, ap);
}
I don't understanding well about your implementation of vasprintf(), but since I've never use it ...
I guess you can free(ptr) that it returns in the **strp??
RichardS