Do VkObjects need to be nulled, or is it solved somehow in automatic way?
- For example when I have Buffer class which is wrapper for
VkBuffer _buffer;
and destructor like this:
Buffer::~Buffer()
{
vkDestroyBuffer(_device.getLogicalDevice(), _buffer, nullptr);
if(_memory) {
vkFreeMemory(_device.getLogicalDevice(), _memory, nullptr);
}
}
Do I need to set, after destructor is called, _buffer to VK_NULL_HANDLE or nullptr or it is not necessary and this is done in automatic way?
(Basically what is my question is if specification stands in which state is left the object instance after calling vkDestroyXYZ / vkFreeXYZ)
And if yes, it applies for all VkObjects (like VkInstance
, VkImage
, etc.) or there are some exceptions?
I thought I am pretty OK if I left the object as it is (especially when it is immediately destroyed after), but we come to this discussion during the code review and lets say, that my reviewer has set -pedantic and -Wall for the sake of our code base I must admit :)