This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: freeing NULL pointer


On 10/04/2010 12:52 a.m., John (Eljay) Love-Jensen wrote:
Hi Cedric,

Doesn't C99 (7.20.3.2) says passing NULL to free() just does nothing?

Could be.


I'm behind the times with C99. I last used C in 1989.

I am not sure if the Standard C Library calls from C++ will comply with C99.

The C89 draft says:


"4.10.3.2 The free function

Synopsis

         #include <stdlib.h>
         void free(void *ptr);

Description

   The free function causes the space pointed to by ptr to be
deallocated, that is, made available for further allocation.  If ptr
is a null pointer, no action occurs.  Otherwise, if the argument does
not match a pointer earlier returned by the calloc , malloc , or
realloc function, or if the space has been deallocated by a call to
free or realloc , the behavior is undefined."

Cheers,
Nicholas Sherlock


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]