|
From: Gil <gil...@fr...> - 2004-01-10 23:12:47
|
free(ptr) cannot put ptr to NULL, simply because you don't pass the
address of ptr.
If you would that all you ptr that are freed, are set to NULL. Define a
fonction that do:
void freeN(void **ptr) {
free(*ptr);
ptr =3D NULL;
}
Date: Sat, 10 Jan 2004 17:43:05 +0100
From: =3D?ISO-8859-1?Q?OROSZI_Bal=3DE1zs?=3D <or...@vp...>
To: dev...@li...
Subject: Re: [Dev-C++] malloc and free
Siva Chandra wrote:
> firstly, thanx Daniel and Oroszi
"Bal=E1zs" - that's my firstname, written at second place (we Hungarians =
are "crazy" people - or maybe everyone else is, except us? :D
> for the descriptive
> replyies. I have always thought free(ptr) would put
> ptr to NULL.
I think you cannot even assume that anywhere. The docs of free() only=20
tell you, that the memory is freed. However, maybe it's a documentation=20
"bug", it doesn't state explicitly that free() is NOT GUARANTEED to put=20
NULL to the deallocated memory (probably because of performance
reasons).
--
Greetings,
Bal=E1zs
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.560 / Virus Database: 352 - Release Date: 08/01/2004
=20
|