9/12/2007

malloc(0) 的问题


char *p;
p = (char *)malloc(0);


以上代码没有错误,但 p 的分配的空间大小是多少呢,不确定?
至于为什么可以分配成功,看看 malloc 的说明就明白了:

malloc returns a void pointer to the allocated space,or null if there is insufficient memory available.

没有评论: