aboutsummaryrefslogtreecommitdiffstats
path: root/io/vaswprintf.c
blob: 8568dfd682e9889c11a8710be5a4941da3e9b418 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "../memory.h"
#include "io.h"

int vaswprintf(wchar_t **string, wchar_t const *restrict format, va_list arg)
{
	va_list tmp;
	va_copy(tmp, arg);
	int lenght = _vswprintf_wrap(NULL, 0, format, tmp);
	va_end(tmp);
	if (lenght < 0) {
		return 1;
	}
	*string = reallocarray(NULL, (size_t)lenght + 1, sizeof *string);
	if (*string == NULL) {
		return 1;
	}
	return _vswprintf_wrap(*string, (size_t)lenght + 1, format, arg);
}