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: Andrew Cagney <ac131313 at cygnus dot com>
- Date: Wed, 15 Nov 2000 09:48:56 +1100
- Cc: GDB Patches <gdb-patches at sourceware dot cygnus dot com>
- References: <3A0F81A1.DB7C9B1E@cygnus.com> <3A1154ED.905D9238@cygnus.com>
Fernando Nasser wrote:
>
> Good catch. No more memory would cause an attempt to free NULL.
> (Have you ever considered a FREE macro that tests for NULL pointers?
> Something like that is used in gdbtk).
> #define FREEIF(x) if (x != NULL) free((char *) (x))
I've always wondered about xfree().
> Maybe you should have "memory exhausted" or something similar in the message text.
> The only reason malloc can fail is ENOMEM.
> Something like "vasprintf: not enough memory".
>
> The second test doesn't seem necessary, as the worse that will happen is the
> message not being printed.
> And I am not sure errno is set in this case, so it may be misleading.
> Furthermore, the only return code less than zero was -1 and will not exist
> in libc starting at 2.1 (accordingly to the man page).
The two tests motivated by an e-mail report I got that a version of
glibc was failing with really bizare error status messages so I decided
to check everything :-). Something to do with a bad unicode sequence.
The details were on the bug-gdb list.
Andrew