Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* xfree() -- set ptr to nil (fwd)
@ 2001-02-12 15:07 John R. Moore
  2001-02-12 15:21 ` Kevin Buettner
  2001-02-12 15:25 ` J.T. Conklin
  0 siblings, 2 replies; 9+ messages in thread
From: John R. Moore @ 2001-02-12 15:07 UTC (permalink / raw)
  To: gdb-patches

Whilst fixing xfree() callsI noticed that xfree() itself has a peculiarity
that needs attention:

The call goes like this:

if (ptr != NULL)
  free(ptr);

Nice, but why not the following:

if (ptr)
  {
     free (ptr);
     prt = NULL);
  }

The latter catches any re-calls to xfree(), unless the compiler sets the
ptr to nil for one (gcc doesn't appear to). Anyhow, it's a good practice
to do this anyhow.

Any opinions?  The only reason I can think not to is to insure that gdb
core dumps on succesive xfree() calls to the same pointer (and hence
insure efficient code, but in that case, why bother with xfree() in the
first place.

John Moore



^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: xfree() -- set ptr to nil (fwd)
@ 2001-02-12 16:01 Michael Elizabeth Chastain
  2001-02-13 14:12 ` Andrew Cagney
  0 siblings, 1 reply; 9+ messages in thread
From: Michael Elizabeth Chastain @ 2001-02-12 16:01 UTC (permalink / raw)
  To: jmoore, kevinb; +Cc: gdb-patches

John Moore writes:

> Ok, then, do we want to replace xfree() with something like XFREE() ?

This gets into a philosophical discussion.  Here is my philosophy.
Others may differ.

Basically, I am interested in work that leads to patches that get applied
and have concrete, observable gains.  If someone can identify specific
bugs that we've had in gdb as a result of xfree problems, then I would
be interested in safety work such as s/xfree/XFREE/g, arranging to run
gdb regularly under Purify, and projects like that.

But I haven't seen problems like that so s/xfree/XFREE/g does not appeal
to me.

This is just a guideline.  I really liked Kevin Buettner's PARAMS removal
patches, for example.  In that case, the code afterwards was uneqivocally
simpler than the code before.

My two cents.  And I'm not a maintainer, just a write-after-approval guy.

Michael Elizabeth Chastain
<chastain@redhat.com>
"love without fear"


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2001-02-13 14:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-02-12 15:07 xfree() -- set ptr to nil (fwd) John R. Moore
2001-02-12 15:21 ` Kevin Buettner
2001-02-12 15:33   ` John R. Moore
2001-02-12 15:46     ` Daniel Berlin
2001-02-12 15:52       ` John R. Moore
2001-02-12 15:54     ` J.T. Conklin
2001-02-12 15:25 ` J.T. Conklin
2001-02-12 16:01 Michael Elizabeth Chastain
2001-02-13 14:12 ` Andrew Cagney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox