Use calloc instead of alloc
authorChristophe <christophe@lunarg.com>
Mon, 13 Feb 2023 14:34:50 +0000 (15:34 +0100)
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Tue, 14 Feb 2023 17:30:44 +0000 (10:30 -0700)
loader/loader.c
tests/loader_regression_tests.cpp

index 0c2dcfe7dda1e74e573faaf5c6ae275b8d02f1a0..6831bcac9c511bd22332aace57b32e84499f6e6d 100644 (file)
@@ -4712,18 +4712,16 @@ VkResult loader_create_instance_chain(const VkInstanceCreateInfo *pCreateInfo, c
 
     if (pCreateInfo->enabledLayerCount > 0 && pCreateInfo->ppEnabledLayerNames != NULL) {
         inst->enabled_layer_count = pCreateInfo->enabledLayerCount;
-        inst->enabled_layer_names = (char**)pCreateInfo->ppEnabledLayerNames;
-        /*
-        inst->enabled_layer_names = (char **)loader_instance_heap_alloc(inst, sizeof(char *) * pCreateInfo->enabledLayerCount,
+
+        inst->enabled_layer_names = (char **)loader_instance_heap_calloc(inst, sizeof(char *) * pCreateInfo->enabledLayerCount,
                                                                         VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
 
         for (uint32_t i = 0, n = inst->enabled_layer_count; i < n; ++i) {
             size_t size = strlen(pCreateInfo->ppEnabledLayerNames[i]) + 1;
-            inst->enabled_layer_names[i] = (char *)loader_instance_heap_alloc(inst, sizeof(char) * size, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
-            memset(inst->enabled_layer_names[i], '\0', sizeof(char) * size);
+            inst->enabled_layer_names[i] =
+                (char *)loader_instance_heap_calloc(inst, sizeof(char) * size, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
             strcpy(inst->enabled_layer_names[i], pCreateInfo->ppEnabledLayerNames[i]);
         }
-        */
     }
 
     if (inst->expanded_activated_layer_list.count > 0) {
index 6d3a02c5c5b9a99c642fcebbd17b33b7978535f5..0f1d436f273eaa62e023c0451b9a0ce2e74ae273 100644 (file)
@@ -1027,7 +1027,7 @@ TEST(CreateDevice, UnmatchInstanceAndDeviceLayers) {
 
     ASSERT_TRUE(log.find("loader_create_device_chain: Using deprecated and ignored 'ppEnabledLayerNames' member of 'VkDeviceCreateInfo' when creating a Vulkan device."));
 }
-/*
+
 // Device layers are deprecated.
 // Ensure that when VkInstanceCreateInfo is deleted, the check of the instance layer lists is running correctly during VkDevice creation
 // https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#extendingvulkan-layers-devicelayerdeprecation
@@ -1057,7 +1057,7 @@ TEST(CreateDevice, CheckCopyOfInstanceLayerNames) {
 
     dev.CheckCreate(phys_dev);
 }
-*/
+
 TEST(CreateDevice, ConsecutiveCreate) {
     FrameworkEnvironment env{};
     env.add_icd(TestICDDetails(TEST_ICD_PATH_VERSION_2));