blob: c69e5f3207c32914e2710ba745313bfbac3b6c6f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
#include "testHelpers.h"
#include <cstdarg>
std::unique_ptr<char, decltype(&free)>
uasprintf(const char * fmt, ...)
{
char * buf {};
va_list args;
va_start(args, fmt);
if (vasprintf(&buf, fmt, args) < 0) {
va_end(args);
return {nullptr, &free};
}
va_end(args);
return std::unique_ptr<char, decltype(&free)> {buf, &free};
}
|