Removing gfc_free()
Janne Blomqvist
blomqvist.janne@gmail.com
Sun Mar 6 19:00:00 GMT 2011
On Sat, Mar 5, 2011 at 16:01, FX <fxcoudert@gmail.com> wrote:
> It has apparently been decided that the long-standing issue of having to check for NULL pointers before calling free() is not an issue anymore in GCC and binutils (well, it's valid ANSI C, so it was bound to disappear at some point). See the thread at http://gcc.gnu.org/ml/gcc-patches/2011-03/msg00226.html for more information.
>
> As such, I thought it might be useful to mention it on this list, because the Fortran front-end uses:
>
>> void
>> gfc_free (void *p)
>> {
>> /* The parentheses around free are needed in order to call not
>> the redefined free of gfortran.h. */
>> if (p != NULL)
>> (free) (p);
>> }
>
> gfc_free() is called 210 times in the front-end. As I understand it, 4.6 is about to be branched, so a big nop patch may be a good candidate for going either (i) short time before branching, to ease backporting patches between then-trunk and 4.6; (ii) shortly after branching, so as not to disrupt development in the middle of, say, stage 1.
Good point. FWIW, we have some similar usage in libgfortran as well where we do
if (foo)
free (foo);
or something roughly similar in io/fbuf.c, io/format.c,
io/list_read.c, io/open.c, io/unit.c, io/unix.c.
Also, what about generated code? IIRC Tobias and/or Richi fixed a case
with temporary arrays, are there any other cases where the NULL test
before freeing can be safely left out?
IMHO this can wait until stage 1 opens, but I have no strong opinions
on the matter.
--
Janne Blomqvist
More information about the Fortran
mailing list