summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Kramkowski <tk@the-tk.com>2018-03-01 14:12:35 +0000
committerTomasz Kramkowski <tk@the-tk.com>2018-03-01 14:43:24 +0000
commit032b0b6a16de49063f2b1563f097533548800c49 (patch)
treecc1f0469a615d0c91758312a19e788d231b83d50
parent5d05f6b155eba68f6de9b0d32a6914449e45a385 (diff)
downloadvulkan-032b0b6a16de49063f2b1563f097533548800c49.tar.gz
vulkan-032b0b6a16de49063f2b1563f097533548800c49.tar.xz
vulkan-032b0b6a16de49063f2b1563f097533548800c49.zip
fix multiple memory leaks
Some minor memory leaks have been fixed (found with valgrind).
-rw-r--r--vulkan.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/vulkan.c b/vulkan.c
index 706a842..c20a436 100644
--- a/vulkan.c
+++ b/vulkan.c
@@ -288,6 +288,8 @@ static VkDevice createdev(VkPhysicalDevice phy, const int *qf)
if (res != VK_SUCCESS)
eprintf("Could not create device");
+ sl_free(&layers);
+
return dev;
}
@@ -391,6 +393,12 @@ static void createswp(struct swp *swp, VkSurfaceKHR surf, VkDevice dev, const in
vkGetSwapchainImagesKHR(dev, swp->swp, &swp->imgs.count, swp->imgs.list);
}
+void destroyswp(struct swp *swp, VkDevice dev)
+{
+ vkDestroySwapchainKHR(dev, swp->swp, NULL);
+ free(swp->imgs.list);
+}
+
static void createviews(struct views *views, VkDevice dev, const struct swpimgs *imgs, VkFormat fmt)
{
VkImageViewCreateInfo info;
@@ -431,6 +439,7 @@ static void createviews(struct views *views, VkDevice dev, const struct swpimgs
static void destroyviews(struct views *views, VkDevice dev)
{
LIST_FOREACH(views, i) vkDestroyImageView(dev, views->list[i], NULL);
+ free(views->list);
}
static VkShaderModule createsmod(VkDevice dev, const void *data, size_t size)
@@ -665,6 +674,7 @@ static void createfbs(struct fbs *fbs, VkDevice dev, const struct views *views,
static void destroyfbs(struct fbs *fbs, VkDevice dev)
{
LIST_FOREACH(fbs, i) vkDestroyFramebuffer(dev, fbs->list[i], NULL);
+ free(fbs->list);
}
static VkCommandPool createcpool(struct cmdbufs *cmdbufs, VkDevice dev, const int *qf,
@@ -833,12 +843,12 @@ int main(void)
vkDestroySemaphore(dev, semfin, NULL);
vkDestroySemaphore(dev, semavail, NULL);
vkDestroyCommandPool(dev, cpool, NULL);
+ free(cmdbufs.list);
destroyfbs(&fbs, dev);
destroyppln(&ppln, dev);
vkDestroyRenderPass(dev, pass, NULL);
destroyviews(&views, dev);
- free(views.list);
- vkDestroySwapchainKHR(dev, swp.swp, NULL);
+ destroyswp(&swp, dev);
vkDestroySurfaceKHR(inst, surf, NULL);
vkDestroyDevice(dev, NULL);
freeswpdtl(&sdtl);