I'm doing Info manager for Dxgi and id like to allocate memory for my message but it writes that problem, any other solution
HRESULT hr;
SIZE_T messageLength;
// get the size of message i in yte
GFX_THROW_NOINFO(pDxgiInfoQueue->GetMessage(DXGI_DEBUG_ALL, i, nullptr, &messageLength));
auto bytes = std::make_unique<byte[]>(messageLength);
And this is the code after that
auto pMessage = reinterpret_cast<DXGI_INFO_QUEUE_MESSAGE*>(bytes.get());
// get the message and push its description into the vector
GFX_THROW_NOINFO(pDxgiInfoQueue->GetMessage(DXGI_DEBUG_ALL, i, pMessage, &messageLength));
messages.emplace_back(pMessage->pDescription);
I would suggest using a std::vector
in this case
std::vector<byte> bytes(messageLength);
then later
auto pMessage = reinterpret_cast<DXGI_INFO_QUEUE_MESSAGE*>(bytes.data());