Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!ucsd!ucbvax!ucsfcgl!cca.ucsf.edu!wet!noah From: noah@wet.UUCP (Noah Spurrier) Newsgroups: comp.lang.c Subject: free (NULL); Keywords: free Message-ID: <1194@wet.UUCP> Date: 6 May 90 21:21:42 GMT Organization: Wetware Diversions, San Francisco Lines: 33 Is there anything wrong with freeing a NULL? pointer? I have a function that uses a static pointer. Everytime the function is called it frees up the previous pointer using free, but the first time the function is called there is nothing to free; the static pointer is initialized to NULL. This is a good example of one of those annoying functions that work great as long as they don't have a first time case. Here is what I am doing... 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. if (test != NULL) free (test); Will angry things happen if I try to free(NULL) ? yours, Noah Spurrier noah@WET.UUCP