This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [rfc] asprintf() -> xasprintf()
- To: Fernando Nasser <fnasser at cygnus dot com>
- Subject: Re: [rfc] asprintf() -> xasprintf()
- From: fche at redhat dot com (Frank Ch. Eigler)
- Date: 14 Nov 2000 11:00:55 -0500
- Cc: Andrew Cagney <ac131313 at cygnus dot com>, GDB Patches <gdb-patches at sourceware dot cygnus dot com>
- References: <3A0F81A1.DB7C9B1E@cygnus.com> <3A1154ED.905D9238@cygnus.com>
Fernando Nasser <fnasser@cygnus.com> writes:
: Good catch. No more memory would cause an attempt to free NULL.
: (Have you ever considered a FREE macro that tests for NULL pointers? [...]
free(NULL) is defined in even old standards to be a no-op.
: [...]
: > + void
: > + xvasprintf (char **ret, const char *format, va_list ap)
: > + {
: > + int status = vasprintf (ret, format, ap);
: > + if ((*ret) == NULL)
: > + internal_error ("%s:%d: vasprintf returned NULL buffer (errno %d)",
: > + __FILE__, __LINE__, errno);
: > + if (status < 0)
: > + internal_error ("%s:%d: vasprintf call failed (errno %d)",
: > + __FILE__, __LINE__, errno);
: > + }
Is __FILE__ and __LINE__ at all informative in these cases? These are
plain functions, not macros, so the same strings will be printed
regardless of the location of the caller.
- FChE