Re: [AD] fixes.. malloc() |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I wrote:
> > You are right, these should be removed. I find it's best not to
> > check before calling free() because you could write the check the
> > wrong way around and end up not freeing valid pointers, but only 0
> > pointers!
On Monday 16 December 2002 10:22, Vincent Penquerc'h wrote:
> OTOH, I've never liked this rule, so I make a point of always
> checking pointers, when they can be NULL. This looks like a wart
> in the spec (which they unfortunately have brought to C++ delete).
> Just to voice my point :)
No, this makes perfect sense. It helps (greatly) to improve readability,
reliability, etc. And C++'s delete operator can be used on a 0 pointer
with no problem. The only possible 'wart' is the fact that the pointer
isn't reset to 0 after freeing - something that is very annoying and
the cause of many, many bugs.
Bye for now,
- --
Laurence Withers, lwithers@xxxxxxxxxx
(GnuPG 04A646EA) http://www.lwithers.demon.co.uk/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQE9/b0EUdhclgSmRuoRAlx3AKCgE5ZBI0lvpFP9OdGNnZjUWxkpyACgo4fR
dZBXnnwQ63FFzYgeucODfqE=
=abnI
-----END PGP SIGNATURE-----