delete a NULL pointer is safe
来源:互联网 发布:http aq.js cj.com 编辑:程序博客网 时间:2024/05/17 02:03
C programmer often writes codes in the following fashion:
if(p){
free(p);
p = NULL;
}
But in C++ scenario, the check of NULL is useless!
C++ guarantees that operator delete checks its argument for null-ness. If the argument is 0, the delete expression has no effect. In other words, deleting a null pointer is a safe (yet useless) operation. There is no need to check the pointer for null-ness before passing it to delete:
if(p) // useless; delete already checks for a null value
delete(p);
转载http://blog.csdn.net/psusong/article/details/5048791
- delete a NULL pointer is safe
- delete a NULL pointer is safe
- getFrameAtTime: videoFrame is a NULL pointer解决办法
- opencv遇到NULL pointer(NULL array pointer is passed) 解决方案
- Is it safe to delete ~/Library/Caches?
- Dereferencing a __weak pointer is not allowed due to possible null value caused by race condition, a
- How to declare a null pointer
- cannot delete name node is in safe mode
- Cannot delete .... . Name node is in safe mode
- Null pointer (NULL array pointer is passed) in function cvGetMat, 报这样的错
- null pointer
- Pointer is missing a nullability type specifier
- a pointer with NULL value calls a function
- git使用,VirtualAlloc pointer is null, Win32 error 487...........
- Delete a node WITHOUT using the HEAD pointer.
- How to set NULL to a pointer in Managed C++?
- 【翻译小手记】This is a dolphin-safe book.
- Hadoop 异常记录 Cannot delete /tmp/hadoop/mapred/system. Name node is in safe mode.
- The C10K problem翻译
- linux /dev目录
- Visual Studio 2008 C++ code slower than Visual Studio 2005
- JQuery上传插件Uploadify使用详解
- 由 ORA-01536: space quota exceeded for tablespace 引出的研究
- delete a NULL pointer is safe
- android语音识别demo
- Win32消息
- 使用 rsync 参数及设置
- Hibernate.cfg.xml相关的参数配置
- 解决:No module named site
- ZooKeeper系列之一:ZooKeeper简介
- JAVA实现大数加法
- iframe自適應高度