layers: Remove unnecessary null pointer checks
Fixes GitHub Issue #6
diff --git a/layers/draw_state.cpp b/layers/draw_state.cpp
index 15abb11..a90b3bd 100644
--- a/layers/draw_state.cpp
+++ b/layers/draw_state.cpp
@@ -2076,15 +2076,9 @@
if ((*ii).second->graphicsPipelineCI.stageCount != 0) {
delete[] (*ii).second->graphicsPipelineCI.pStages;
}
- if ((*ii).second->pVertexBindingDescriptions) {
- delete[] (*ii).second->pVertexBindingDescriptions;
- }
- if ((*ii).second->pVertexAttributeDescriptions) {
- delete[] (*ii).second->pVertexAttributeDescriptions;
- }
- if ((*ii).second->pAttachments) {
- delete[] (*ii).second->pAttachments;
- }
+ delete[] (*ii).second->pVertexBindingDescriptions;
+ delete[] (*ii).second->pVertexAttributeDescriptions;
+ delete[] (*ii).second->pAttachments;
if ((*ii).second->dynStateCI.dynamicStateCount != 0) {
delete[] (*ii).second->dynStateCI.pDynamicStates;
}
@@ -2953,9 +2947,7 @@
// Freeing layouts handled in deleteLayouts() function
// Free Update shadow struct tree
freeShadowUpdateTree(pFreeSet);
- if (pFreeSet->ppDescriptors) {
- delete[] pFreeSet->ppDescriptors;
- }
+ delete[] pFreeSet->ppDescriptors;
delete pFreeSet;
}
delete (*ii).second;
@@ -2973,8 +2965,7 @@
LAYOUT_NODE* pLayout = (*ii).second;
if (pLayout->createInfo.pBindings) {
for (uint32_t i=0; i<pLayout->createInfo.bindingCount; i++) {
- if (pLayout->createInfo.pBindings[i].pImmutableSamplers)
- delete[] pLayout->createInfo.pBindings[i].pImmutableSamplers;
+ delete[] pLayout->createInfo.pBindings[i].pImmutableSamplers;
}
delete[] pLayout->createInfo.pBindings;
}
@@ -4785,10 +4776,8 @@
loader_platform_thread_unlock_mutex(&globalLock);
} else {
for (i=0; i<count; i++) {
- if (pPipeNode[i]) {
- // Clean up any locally allocated data structures
- delete pPipeNode[i];
- }
+ // Clean up any locally allocated data structures
+ delete pPipeNode[i];
}
loader_platform_thread_unlock_mutex(&globalLock);
return VK_ERROR_VALIDATION_FAILED_EXT;
@@ -6910,9 +6899,7 @@
return;
for (auto ii=my_data->renderPassMap.begin(); ii!=my_data->renderPassMap.end(); ++ii) {
const VkRenderPassCreateInfo* pRenderPassInfo = (*ii).second->pCreateInfo;
- if (pRenderPassInfo->pAttachments) {
- delete[] pRenderPassInfo->pAttachments;
- }
+ delete[] pRenderPassInfo->pAttachments;
if (pRenderPassInfo->pSubpasses) {
for (uint32_t i=0; i<pRenderPassInfo->subpassCount; ++i) {
// Attachements are all allocated in a block, so just need to
@@ -6929,9 +6916,7 @@
}
delete[] pRenderPassInfo->pSubpasses;
}
- if (pRenderPassInfo->pDependencies) {
- delete[] pRenderPassInfo->pDependencies;
- }
+ delete[] pRenderPassInfo->pDependencies;
delete pRenderPassInfo;
delete (*ii).second;
}
diff --git a/layers/draw_state.h b/layers/draw_state.h
index c7435c4..d17a218 100755
--- a/layers/draw_state.h
+++ b/layers/draw_state.h
@@ -468,9 +468,7 @@
}
}
~_DESCRIPTOR_POOL_NODE() {
- if (createInfo.pPoolSizes) {
- delete[] createInfo.pPoolSizes;
- }
+ delete[] createInfo.pPoolSizes;
// TODO : pSets are currently freed in deletePools function which uses freeShadowUpdateTree function
// need to migrate that struct to smart ptrs for auto-cleanup
}
@@ -701,7 +699,6 @@
}
~_SWAPCHAIN_NODE()
{
- if (pQueueFamilyIndices)
- delete pQueueFamilyIndices;
+ delete pQueueFamilyIndices;
}
} SWAPCHAIN_NODE;
diff --git a/layers/unique_objects.h b/layers/unique_objects.h
index 3ce6dda..5dab3c8 100644
--- a/layers/unique_objects.h
+++ b/layers/unique_objects.h
@@ -448,8 +448,7 @@
}
// CODEGEN : file /usr/local/google/home/tobine/vulkan_work/LoaderAndTools/vk-layer-generate.py line #1671
VkResult result = get_dispatch_table(unique_objects_device_table_map, device)->CreateComputePipelines(device, pipelineCache, createInfoCount, (const VkComputePipelineCreateInfo*)local_pCreateInfos, pAllocator, pPipelines);
- if (local_pCreateInfos)
- delete[] local_pCreateInfos;
+ delete[] local_pCreateInfos;
if (VK_SUCCESS == result) {
VkUniqueObject* pUO = NULL;
for (uint32_t i=0; i<createInfoCount; ++i) {
@@ -493,8 +492,7 @@
}
// CODEGEN : file /usr/local/google/home/tobine/vulkan_work/LoaderAndTools/vk-layer-generate.py line #1671
VkResult result = get_dispatch_table(unique_objects_device_table_map, device)->CreateGraphicsPipelines(device, pipelineCache, createInfoCount, (const VkGraphicsPipelineCreateInfo*)local_pCreateInfos, pAllocator, pPipelines);
- if (local_pCreateInfos)
- delete[] local_pCreateInfos;
+ delete[] local_pCreateInfos;
if (VK_SUCCESS == result) {
VkUniqueObject* pUO = NULL;
for (uint32_t i=0; i<createInfoCount; ++i) {
diff --git a/tests/vkrenderframework.cpp b/tests/vkrenderframework.cpp
index edcc93c..1ff382b 100644
--- a/tests/vkrenderframework.cpp
+++ b/tests/vkrenderframework.cpp
@@ -162,8 +162,7 @@
}
void VkRenderFramework::ShutdownFramework() {
- if (m_commandBuffer)
- delete m_commandBuffer;
+ delete m_commandBuffer;
if (m_commandPool)
vkDestroyCommandPool(device(), m_commandPool, NULL);
if (m_framebuffer)