free (NULL);

Leo de Wit leo at ehviea.ine.philips.nl
Wed May 9 02:28:58 AEST 1990


In article <19461 at duke.cs.duke.edu> drh at cs.duke.edu writes:
|In article <1194 at wet.UUCP> noah at wet.UUCP (Noah Spurrier) writes:
|>
|>Is there anything wrong with freeing a NULL? pointer?
|>
|>char *squirl()
|>{
|>  static char *test = NULL;
|>  free (test);
|>  test = (char *) malloc (100);
|>  return (test);
|>}
|>
|>This function is run many times so iI do not want to protect it with an if
|>because the if would only be useful for the first time it is run, after that
|>it just eats up run time.
|
|1.  Different implementation do different things with NULL pointers
|    passed to free().  I find it best to assume that it is illegal
|    to not give a null pointer to free().

I guess this states you cannot safely call free() ?

:-)

    Leo.



More information about the Comp.lang.c mailing list