2
* Copyright (C) 2009 Citrix Ltd.
3
* Author Stefano Stabellini <stefano.stabellini@eu.citrix.com>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU Lesser General Public License as published
7
* by the Free Software Foundation; version 2.1 only. with the special
8
* exception on linking described in file LICENSE.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU Lesser General Public License for more details.
16
#include "libxl_osdeps.h"
24
#ifdef NEED_OWN_ASPRINTF
26
int vasprintf(char **buffer, const char *fmt, va_list ap)
33
nchars = vsnprintf(*buffer, 0, fmt, ap);
38
/* Reallocate buffer now that we know how much space is needed. */
40
tmpbuff = (char*)realloc(*buffer, size);
43
if (tmpbuff == NULL) { /* we need to free it*/
50
nchars = vsnprintf(*buffer, size, fmt, ap);
53
if (nchars < 0) return nchars;
57
int asprintf(char **buffer, char *fmt, ...)
63
status = vasprintf (buffer, fmt, ap);