#include <stdioprivate.h>
#include <strstream.h>

extern "C" int vsprintf(char* string, const char* format, va_list args)
{
#if 1
    // Buggy g++
    strstreambuf *stream = new strstreambuf(string, -1, string);
    int ret = __vsbprintf(stream, format, args);
    stream->sputc(0);
    delete stream;
#else
    strstreambuf stream(string, -1, string);
    int ret = __vsbprintf(&stream, format, args);
    stream.sputc(0);
#endif
    return ret;
}
