- va_list args_copy;
- va_copy(args_copy, args);
- int length = vsnprintf(NULL, 0, format, args_copy);
- va_end(args_copy);
- char *buf = (char *) g_malloc(length + 1);
- vsprintf(buf, format, args);
- string message(buf, length);
- g_free(buf);
+ const unique_ptr<char, decltype(&g_free)>
+ message {g_strdup_vprintf(format, args), &g_free};