diff options
-rw-r--r-- | main.c | 24 |
1 files changed, 11 insertions, 13 deletions
@@ -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; |