-static char *output = NULL;
-
-static int saved_vprintf(const char *fmt, va_list ap)
-{
- int ret = vsnprintf(NULL, 0, fmt, ap);
- int len = 0;
-
- if (output)
- len = strlen(output);
-
- output = realloc(output, len + ret + 1);
- return vsprintf(output + len, fmt, ap);
-}
-
-static int saved_printf(const char *fmt, ...)
-{
- va_list ap;
- int ret;
-
- va_start(ap, fmt);
- ret = saved_vprintf(fmt, ap);
- va_end(ap);
- return ret;
-}
-
-static int saved_fprintf(FILE *ignored, const char *fmt, ...)
-{
- va_list ap;
- int ret;
-
- va_start(ap, fmt);
- ret = saved_vprintf(fmt, ap);
- va_end(ap);
- return ret;
-}
-