summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Halase <jordan@halase.me>2019-10-28 19:56:33 -0500
committerJordan Halase <jordan@halase.me>2019-10-28 19:56:33 -0500
commitf36940f72838eacd7fe6fac627f0855620519a62 (patch)
tree234b2df2f0363b746939d20f320bfd026eb49371
parent56a010b06547b7d414185dbd2532ce209226078c (diff)
Make code easier
-rw-r--r--main.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/main.c b/main.c
index 911e5d7..0d479b8 100644
--- a/main.c
+++ b/main.c
@@ -86,15 +86,11 @@ struct RenderVulkan {
VkDevice device;
};
-struct RenderVulkan *vk;
-
#define ERRMSG_LEN 4096
void setErrMsg(struct RenderVulkan *vk, const char *fmt, ...)
{
- if (!vk->errMsg) {
- vk->errMsg = calloc(1, ERRMSG_LEN);
- }
+ vk->errMsg = realloc(vk->errMsg, ERRMSG_LEN);
va_list args;
va_start(args, fmt);
stbsp_vsnprintf(vk->errMsg, ERRMSG_LEN, fmt, args);
@@ -531,24 +527,26 @@ done:
free(devices);
}
-int main()
+void rvkCheckFatal(struct RenderVulkan *vk)
{
const char *errMsg = NULL;
- struct RenderVulkan *vk = renderVulkanCreate();
if ((errMsg = getErrMsg(vk))) {
fprintf(stderr, "%s\n", errMsg);
renderVulkanDestroy(vk);
- return 1;
+ exit(1);
}
+}
+
+int main()
+{
+ const char *errMsg = NULL;
+ struct RenderVulkan *vk = renderVulkanCreate();
+ rvkCheckFatal(vk);
printf("Created Vulkan Instance Successfully\n");
selectPhysicalDevice(vk);
- if ((errMsg = getErrMsg(vk))) {
- fprintf(stderr, "%s\n", errMsg);
- renderVulkanDestroy(vk);
- return 1;
- }
+ rvkCheckFatal(vk);
renderVulkanDestroy(vk);
return 0;