From: Christophe Date: Mon, 13 Feb 2023 14:34:50 +0000 (+0100) Subject: Use calloc instead of alloc X-Git-Tag: upstream/1.3.268~222 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=933f8694effb75c1249e736eb7bfbdc66d9e0ae0;p=platform%2Fupstream%2FVulkan-Loader.git Use calloc instead of alloc --- diff --git a/loader/loader.c b/loader/loader.c index 0c2dcfe7..6831bcac 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -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) { diff --git a/tests/loader_regression_tests.cpp b/tests/loader_regression_tests.cpp index 6d3a02c5..0f1d436f 100644 --- a/tests/loader_regression_tests.cpp +++ b/tests/loader_regression_tests.cpp @@ -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));