malloc(0)的意义。
上次看到书上说malloc(0)会返回一个正确的指针,是为了任何两个分配的内存有不同的地址,但是看到c++ 对象模型时,上面又说这种机制是为了保证临时对象的行为的,不懂。到底意义何在,请高人指点。
[解决办法]
来自C99的最权威的解释:If the size of the space requested is zero, the behavior is implementationdefined:either a null pointer is returned, or the behavior is as if the size were somenonzero value, except that the returned pointer shall not be used to access an object.