在某坛子里面逛 看到有些人再批
if( p == NULL ) delete p;
p = NULL;

很好奇的看了下去
原来 delete 和 free都是支持NULL指针的啊

  C99 7.20.3.2 The free function
The free function causes the space pointed to by ptr to be deallocated, that is, made available for further allocation. If ptr is a null pointer, no action occurs.

C++98 5.3.5 Delete
if the value of the operand of delete is the null pointer the operation has no effect.
评论
发表评论

您还没有登录,请登录后发表评论

DraculaW
搜索本博客
博客分类
最近加入圈子
存档
最新评论