From 80ff3da61d265f82705728d947a680afa12c5963 Mon Sep 17 00:00:00 2001
From: Tobias Frisch <tfrisch@uni-koblenz.de>
Date: Mon, 3 May 2021 14:11:24 +0200
Subject: [PATCH] [#7] fixed some compiler warnings

Signed-off-by: Tobias Frisch <tfrisch@uni-koblenz.de>
---
 src/vkcv/Context.cpp | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/vkcv/Context.cpp b/src/vkcv/Context.cpp
index e79c2c82..9682ca18 100644
--- a/src/vkcv/Context.cpp
+++ b/src/vkcv/Context.cpp
@@ -17,11 +17,12 @@ namespace vkcv {
 		vkcv::initGLFW();
 
 		// check for layer support
-		uint32_t layerCount = 0;
-		vk::enumerateInstanceLayerProperties(&layerCount, nullptr);
-		std::vector<vk::LayerProperties> layerProperties(layerCount);
-		vk::enumerateInstanceLayerProperties(&layerCount, layerProperties.data());
+		
+		const std::vector<vk::LayerProperties>& layerProperties = vk::enumerateInstanceLayerProperties();
+		
 		std::vector<const char*> supportedLayers;
+		supportedLayers.reserve(layerProperties.size());
+		
 		for (auto& elem : layerProperties) {
 			supportedLayers.push_back(elem.layerName);
 		}
@@ -29,20 +30,24 @@ namespace vkcv {
 // if in debug mode, check if validation layers are supported. Enable them if supported
 #if _DEBUG
 		std::vector<const char*> validationLayers = {
-		"VK_LAYER_KHRONOS_validation"
+			"VK_LAYER_KHRONOS_validation"
 		};
+		
 		if (!Context::checkSupport(supportedLayers, validationLayers)) {
 			throw std::runtime_error("Validation layers requested but not available!");
 		}
 #endif
-
-
+		
 		// check for extension support
 		std::vector<vk::ExtensionProperties> instanceExtensionProperties = vk::enumerateInstanceExtensionProperties();
+		
 		std::vector<const char*> supportedExtensions;
+		supportedExtensions.reserve(instanceExtensionProperties.size());
+		
 		for (auto& elem : instanceExtensionProperties) {
 			supportedExtensions.push_back(elem.extensionName);
 		}
+		
 		if (!checkSupport(supportedExtensions, instanceExtensions)) {
 			throw std::runtime_error("The requested instance extensions are not supported!");
 		}
-- 
GitLab