C++安全删除指针SAFE_DELETE宏
C++安全删除指针SAFE_DELETE宏
在directx工具中有这样几个定义:
#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } } #define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } } #define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
#define :相当于代码替换,而不是函数定义;