1
0
mirror of https://github.com/microsoft/DirectXTex synced 2025-01-13 03:00:05 +00:00

Use SHCreateMemStream instead of CreateStreamOnHGlobal when possible

This commit is contained in:
Chuck Walbourn 2020-11-09 13:15:55 -08:00
parent a403767285
commit c32f12a3c1

View File

@ -57,6 +57,23 @@
#endif // __cplusplus_winrt
#elif (!defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP)) && (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
#include <shlwapi.h>
#pragma comment(lib,"shlwapi.lib")
static inline HRESULT CreateMemoryStream(_Outptr_ IStream** stream) noexcept
{
if (!stream)
return E_INVALIDARG;
*stream = SHCreateMemStream(nullptr, 0u);
if (!*stream)
return E_OUTOFMEMORY;
return S_OK;
}
#else
#pragma prefast(suppress:6387 28196, "a simple wrapper around an existing annotated function" );