2 * Copyright (C) 2003, 2005 Free Software Foundation, Inc.
4 * This file is part of GnuPG.
6 * This file is free software; you can redistribute it and/or modify
7 * it under the terms of either
9 * - the GNU Lesser General Public License as published by the Free
10 * Software Foundation; either version 3 of the License, or (at
11 * your option) any later version.
15 * - the GNU General Public License as published by the Free
16 * Software Foundation; either version 2 of the License, or (at
17 * your option) any later version.
19 * or both in parallel, as here.
21 * This file is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, see <https://www.gnu.org/licenses/>.
36 /* Same as asprintf but return an allocated buffer suitable to be
37 freed using xfree. This function simply dies on memory failure,
38 thus no extra check is required.
40 FIXME: We should remove these functions in favor of gpgrt_bsprintf
41 and a xgpgrt_bsprintf or rename them to xbsprintf and
44 xasprintf (const char *fmt, ...)
50 if (gpgrt_vasprintf (&buf, fmt, ap) < 0)
51 log_fatal ("estream_asprintf failed: %s\n", strerror (errno));
56 /* Same as above but return NULL on memory failure. */
58 xtryasprintf (const char *fmt, ...)
65 rc = gpgrt_vasprintf (&buf, fmt, ap);