Advertisement
pushrbx

SafeRelease

Mar 5th, 2013
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. template <typename T> inline void SafeRelease(T *&pI, bool bDelete = false)
  2. {
  3.     if (pI != NULL)
  4.     {
  5.         pI->Release();
  6.  
  7.         if(bDelete)
  8.             delete pI; // not sure about this;
  9.  
  10.         pI = NULL;
  11.     }
  12. }
  13.  
  14. template <class T> inline void SafeRelease(T **ppT, bool bDelete = false)
  15. {
  16.     if(*ppT != NULL)
  17.     {
  18.         (*ppT)->Release();
  19.  
  20.         if(bDelete)
  21.             delete *ppT; // not sure about thus;
  22.  
  23.         *ppT = NULL;
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement