Environment: vs2008 for two times: malloc and free: malloc, free will leak memory at one time, no phenomenon at that time, but the machine will get slower and slower; malloc once, free twice will certainly make an error. In addition, null can be free for countless times. As for why, I think free is meaningless for null, so it doesn't matter if free is not free. If I want to design a free function, we can also design it like this so that those who suffer from such problems will be entangled.
Deep anatomy of C language p124
"Another question is: Will a null pointer be returned when I use the malloc function to apply for a 0-byte memory? You can test it or find instructions on the malloc function. To apply for a 0-byte memory, the function does not return NULL, but returns a normal memory address. However No Use the memory with a size of 0. This is like a scale on a ruler. the scale itself has no length. Only one or two pieces can be used together to determine the length. Be careful with this 1.1, because at this time if (null! = P) Statement validation will not work. "It is not unusable, but not usable. (It seems like it's almost so good) You can store data to this address, however, it may be overwritten if other memory allocation statements are allocated to other variables.
Char * CP = (char *) malloc (0); * CP = 'q'; // CP = 0x0039210, And the 'q' is saved, the ASCII value is 0x71.
After the experiment, when you apply for a memory of 0 and do not store data, it is no problem to free it;
Char * CP = (char *) malloc (0); free (CP );
When you save a data record and free the pointer, an error is returned ~~~
Char * CP = (char *) malloc (0); * CP = 'q'; // CP = 0x0039210. Why does vs2008 score this? Isn't it random in the stack? It seems that the compiler is not set to random during design. Free (CP); // it is best not to be okay to challenge the compiler's IQ