From dbf67e8a20219bfe08f30c1da94760ac706fa2e2 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Wed, 10 Jul 2019 14:11:56 +0200 Subject: [PATCH] zink: refactor fence destruction Acked-by: Jordan Justen --- src/gallium/drivers/zink/zink_fence.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/zink/zink_fence.c b/src/gallium/drivers/zink/zink_fence.c index 6df13b9eca8..ac761e667a3 100644 --- a/src/gallium/drivers/zink/zink_fence.c +++ b/src/gallium/drivers/zink/zink_fence.c @@ -27,6 +27,14 @@ #include "util/u_memory.h" +static void +destroy_fence(struct zink_screen *screen, struct zink_fence *fence) +{ + if (fence->fence) + vkDestroyFence(screen->dev, fence->fence, NULL); + FREE(fence); +} + struct zink_fence * zink_create_fence(struct pipe_screen *pscreen) { @@ -50,7 +58,7 @@ zink_create_fence(struct pipe_screen *pscreen) return ret; fail: - FREE(ret); + destroy_fence(screen, ret); return NULL; } @@ -59,10 +67,8 @@ zink_fence_reference(struct zink_screen *screen, struct zink_fence **ptr, struct zink_fence *fence) { - if (pipe_reference(&(*ptr)->reference, &fence->reference)) { - vkDestroyFence(screen->dev, (*ptr)->fence, NULL); - free(*ptr); - } + if (pipe_reference(&(*ptr)->reference, &fence->reference)) + destroy_fence(screen, *ptr); *ptr = fence; } -- 2.30.2