layers: Remove unnecessary null pointer checks
authorEric Engestrom <eric@engestrom.ch>
Sun, 21 Feb 2016 19:58:09 +0000 (19:58 +0000)
committerTobin Ehlis <tobine@google.com>
Tue, 23 Feb 2016 19:30:37 +0000 (12:30 -0700)
Fixes GitHub Issue #6

layers/draw_state.cpp
layers/draw_state.h
layers/unique_objects.h

index 15abb11..a90b3bd 100644 (file)
@@ -2076,15 +2076,9 @@ static void deletePipelines(layer_data* my_data)
         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 @@ static void deletePools(layer_data* my_data)
             // 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 @@ static void deleteLayouts(layer_data* my_data)
         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 @@ VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateComputePipelines(
         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 @@ static void deleteRenderPasses(layer_data* my_data)
         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 @@ static void deleteRenderPasses(layer_data* my_data)
             }
             delete[] pRenderPassInfo->pSubpasses;
         }
-        if (pRenderPassInfo->pDependencies) {
-            delete[] pRenderPassInfo->pDependencies;
-        }
+        delete[] pRenderPassInfo->pDependencies;
         delete pRenderPassInfo;
         delete (*ii).second;
     }
index c7435c4..d17a218 100755 (executable)
@@ -468,9 +468,7 @@ typedef struct _DESCRIPTOR_POOL_NODE {
         }
     }
     ~_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 @@ typedef struct _SWAPCHAIN_NODE {
     }
     ~_SWAPCHAIN_NODE()
     {
-        if (pQueueFamilyIndices)
-            delete pQueueFamilyIndices;
+        delete pQueueFamilyIndices;
     }
 } SWAPCHAIN_NODE;
index 3ce6dda..5dab3c8 100644 (file)
@@ -448,8 +448,7 @@ VkResult explicit_CreateComputePipelines(VkDevice device, VkPipelineCache pipeli
     }
 // 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 @@ VkResult explicit_CreateGraphicsPipelines(VkDevice device, VkPipelineCache pipel
     }
 // 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) {