Re: free()
- From: "santosh" <santosh.k83@xxxxxxxxx>
- Date: 13 Feb 2007 08:42:21 -0800
Racaille wrote:
On Feb 10, 2:13 pm, "santosh" <santosh....@xxxxxxxxx> wrote:
things yourself. One safe practise is to immediately set a pointer to
NULL after calling free() on it. Passing a null pointer to free() is
harmless.
this is a very bad idea.
instead of having your code crash like hell in the
first phases of debugging, which will allow you
to fix the thing quick & properly, you will happily
call free() many times on the same pointer, and
build crap around that broken logic, and then
call for a garbage collector :)
I argue that attempting to ensure that pointers are either null or
have legally deferencible values is better. A null pointer is by
definition an unusable pointer. A pointer with an indeterminate value,
on the other hand, may or may not exhibit observable error, when
misused. I prefer to take the more deterministic route.
.
- Follow-Ups:
- Re: free()
- From: CBFalconer
- Re: free()
- From: Richard Bos
- Re: free()
- References:
- free()
- From: dbansal
- Re: free()
- From: santosh
- Re: free()
- From: Racaille
- free()
- Prev by Date: Automatically generate variables
- Next by Date: Re: Automatically generate variables
- Previous by thread: Re: free()
- Next by thread: Re: free()
- Index(es):
Relevant Pages
|