- 论坛徽章:
- 324
|
总是这么的专业。linux中有2种情况,windows中就返回null
rubylc_unix 发表于 2010-12-14 08:52 ![]()
AIX:
If the size requested is 0, malloc returns NULL in normal circumstances. However, if the program was compiled with the
defined _LINUX_SOURCE_COMPAT macro, malloc returns a valid pointer to a space of size 0.
HPUX:
The only external difference between the old malloc(3X) allocator and
the malloc(3C) allocator is that the old allocator would return a NULL
pointer for a request of zero bytes. The malloc(3C) allocator returns
a valid memory address. This is not a concern for most applications.
看了之后更纠结了{:3_189:}
尽量不要malloc 0字节为好 |
|