On Thu, Aug 31, 2000 at 03:48:37PM -0400, Federico Mena Quintero wrote:
> Maurits Rijk <[EMAIL PROTECTED]> writes:
> [ ... ]
> > 3) sometimes it's just lack of C knowledge:
> > 
> >     if (p)
> >        free(p);
> > 
> > can be simply replaced by just: 
> > 
> >     free(p);
> If p is a null pointer then "free (p)" may (and should!) crash.  You
> are incorrect here.
> [ ... ]

  I disagree with you there. Here's an excerpt from the free(3) man page:
         free()  frees  the  memory  space pointed to by ptr, which
         must have been returned by a previous  call  to  malloc(),
         calloc()  or  realloc().   Otherwise,  or if free(ptr) has
         already been called before,  undefined  behaviour  occurs.
         If ptr is NULL, no operation is performed.
  It doesn't says: "If ptr is NULL, the program may crash".


Author of the French Book: Programmation Linux avec GTK+

A man with one watch knows what time it is.
A man with two watches is never quite sure.

Reply via email to