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

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