blob: dcc3061966be646bc734fd7715d9952ee1d313ea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#include <config.h>
#include <stdio.h>
#include "vasprintf.h"
#ifndef HAVE_VASPRINTF
#define MAX_BSIZE 1024
#define NO_MORE_MAX (16*MAX_BSIZE)
int _gnutls_vasprintf(char **strp, const char *fmt, va_list ap)
{
char * buf;
int ret, max;
max = MAX_BSIZE/2;
do
{
max *= 2;
buf = malloc(max);
if (buf == NULL)
return -1;
ret = vsnprintf(buf, max, fmt, ap);
}
while (ret > max && max < NO_MORE_MAX);
return ret;
}
#endif
|