This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
free() vs xfree() vs FREEIF() vs ISO-C
- To: GDB Discussion <gdb at sourceware dot cygnus dot com>
- Subject: free() vs xfree() vs FREEIF() vs ISO-C
- From: Andrew Cagney <ac131313 at cygnus dot com>
- Date: Thu, 30 Nov 2000 12:35:22 +1100
Hello,
One of the issues that fell out of the alloca() discussion was the
portability of free(). While ISO-C guarentees that free(NULL) doesn't
dump core, many pre-ISO-C libc's don't offer that guarentee.
I can think of several ways of refining the coding standard to avoid
this:
o Add/use xfree() which
would guard against NULL.
o adopt FREEIF() for for
the same reason
o leave things as is
and assume people will
remember to check the
arg before calling xfree().
Does anyone have any thoughts? I tend towards the first one as that is
fairly easy to implement. If adopted, I'd beg/borrow/con someone into
converting all free() and free((PTR)) calls into xfree() :-)
Andrew