Oleg Goldshmidt <[EMAIL PROTECTED]> writes: > [EMAIL PROTECTED] writes: > > > For example IIRC the specs don't define what free((void *)0) should > > do, so it can either return cleanly doing nothing or cause a > > segmentation fault depending on the compiler. > > Or send an email to your manager suggesting that your salary should be > revised. It may be done by the same implementation that usually does > nothing when you free(0), depending on the value of a trancendental > function of the phase of the moon and the PID of your program.
Eh, I got carried away by the flow: free(0) is a nop - freeing the same memory twice is what is undefined. From the 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(). Other- wise, or if free(ptr) has already been called before, undefined behaviour occurs. If ptr is NULL, no operation is performed. Thanks to Elad Efrat for pointing it out privately, and sorry for the confusion. -- Oleg Goldshmidt | [EMAIL PROTECTED] | http://www.goldshmidt.org ================================================================= To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]