This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [rfc] asprintf() -> xasprintf()



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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]