Re: free()



Chris Dollin said:

<snip>

When goats are given additional pointer members (such as arms),
freeing a goat will have to deal with this. I find it easiest
to have a goatFree function right from the start, so that
I don't have to go free(aGoat)-hunting and change it.

Yes, likewise, which is why I write the destructor in the way I showed
you.

It might not only be goats that use trollguns, and anyway there may
be other circumstances where you need to destroy a trollgun other
than the one where you are destroying - sorry! deleting - a goat.

Yes - but the same argument applies: either I'm going to destroy
the place that pointed to the gun, so no point nulling it, or I'm
going to give it a new value, so no point nulling it.

No, there's another possibility - that the entity that had the gun no
longer has a gun (I dunno, perhaps the troll rips out the arm that was
holding it or something), and thus NULL is an appropriate value for
that pointer. For me, this is often the case, (not that I use trollguns
very often) - objects gain and lose other objects with careful abandon.

<snip>

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
.



Relevant Pages

  • Re: Note to Phil
    ... You gotta learn to snip. ... To answer your argument - one which seems so all-important to gun ... requires a license in CA. ... Gun laws could address the symptom. ...
    (talk.politics.guns)
  • Re: Note to Phil
    ... You gotta learn to snip. ... To answer your argument - one which seems so all-important to gun ... requires a license in CA. ... Gun laws could address the symptom. ...
    (talk.politics.guns)
  • Re: Note to Phil
    ... You gotta learn to snip. ... To answer your argument - one which seems so all-important to gun ... Laws don't stop the black market. ... You snipped, skipped, then forgot the subject was senior citizens. ...
    (talk.politics.guns)
  • Re: U S - T 34 Tank ?
    ... > or infantry support tank. ... It also has a 75mm gun. ... It's a pretty neat infantry support vehicle. ...
    (soc.history.war.world-war-ii)
  • Re: For John and MFO
    ... >> You need a special permit here to carry a concealed hand gun, ... >> that we don't want to carry hand guns and we don't see a need for it. ... carrying a gun that puts me doubly at risk. ...
    (rec.scuba)