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()


On Tue, Nov 14, 2000 at 11:00:55AM -0500, Frank Ch. Eigler wrote:
> 
> 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.

That doesn't matter.  There are pre-standard systems (sun4, probably old hp/ux)
out there that core dump when free is given a NULL pointer.

> 
> : [...]
> : > + 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.

Ideally you want __FILE__ and __LINE__ passed in from the caller.

-- 
Michael Meissner, Red Hat, Inc.
PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886, USA
Work:	  meissner@redhat.com		phone: +1 978-486-9304
Non-work: meissner@spectacle-pond.org	fax:   +1 978-692-4482

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