Add helper functions to safely release Windows COM resources, and arrays of COM resources.

TRAC #22656 Signed-off-by: Nicolas Capens Signed-off-by: Shannon Woods Author: Jamie Madill git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@2014 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 5030c62a
......@@ -21,6 +21,25 @@ inline unsigned int ArraySize(T(&)[N])
return N;
}
template <typename T, unsigned int N>
void SafeRelease(T (&resourceBlock)[N])
{
for (unsigned int i = 0; i < N; i++)
{
SafeRelease(resourceBlock[i]);
}
}
template <typename T>
void SafeRelease(T& resource)
{
if (resource)
{
resource->Release();
resource = NULL;
}
}
#if defined(_MSC_VER)
#define snprintf _snprintf
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment