projects
/
gnupg.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix gpg-preset-passphrase bug.
[gnupg.git]
/
common
/
xasprintf.c
diff --git
a/common/xasprintf.c
b/common/xasprintf.c
index
75ae180
..
9774d06
100644
(file)
--- a/
common/xasprintf.c
+++ b/
common/xasprintf.c
@@
-5,7
+5,7
@@
*
* GnuPG is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* GnuPG is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version
2
of the License, or
+ * the Free Software Foundation; either version
3
of the License, or
* (at your option) any later version.
*
* GnuPG is distributed in the hope that it will be useful,
* (at your option) any later version.
*
* GnuPG is distributed in the hope that it will be useful,
@@
-14,9
+14,7
@@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
- * USA.
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
*/
#include <config.h>
@@
-25,6
+23,11
@@
#include "util.h"
#include "iobuf.h"
#include "util.h"
#include "iobuf.h"
+#include "estream-printf.h"
+
+#if !defined(_ESTREAM_PRINTF_MALLOC) || !defined(_ESTREAM_PRINTF_FREE)
+#error Need to define ESTREAM_PRINTF_MALLOC and _FREE
+#endif
/* Same as asprintf but return an allocated buffer suitable to be
freed using xfree. This function simply dies on memory failure,
/* Same as asprintf but return an allocated buffer suitable to be
freed using xfree. This function simply dies on memory failure,
@@
-33,15
+36,13
@@
char *
xasprintf (const char *fmt, ...)
{
va_list ap;
xasprintf (const char *fmt, ...)
{
va_list ap;
- char *buf
, *p
;
+ char *buf;
va_start (ap, fmt);
va_start (ap, fmt);
- if (vasprintf (&buf, fmt, ap) < 0)
- log_fatal ("asprintf failed: %s\n", strerror (errno));
+ if (
estream_
vasprintf (&buf, fmt, ap) < 0)
+ log_fatal ("
estream_
asprintf failed: %s\n", strerror (errno));
va_end (ap);
va_end (ap);
- p = xstrdup (buf);
- free (buf);
- return p;
+ return buf;
}
/* Same as above but return NULL on memory failure. */
}
/* Same as above but return NULL on memory failure. */
@@
-50,14
+51,12
@@
xtryasprintf (const char *fmt, ...)
{
int rc;
va_list ap;
{
int rc;
va_list ap;
- char *buf
, *p
;
+ char *buf;
va_start (ap, fmt);
va_start (ap, fmt);
- rc = vasprintf (&buf, fmt, ap);
+ rc =
estream_
vasprintf (&buf, fmt, ap);
va_end (ap);
if (rc < 0)
return NULL;
va_end (ap);
if (rc < 0)
return NULL;
- p = xtrystrdup (buf);
- free (buf);
- return p;
+ return buf;
}
}