aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2023-01-11 11:09:30 -0500
committerDavid Robillard <d@drobilla.net>2023-01-11 11:09:30 -0500
commit0f68cd00eb06ca1d7a4bdbb9e94ec060e784bd50 (patch)
tree8f6f19517dd0d92db17530449c72e91129ccbad6 /src
parentab2a8b226f341c38a6a1cd459addbf4e9af83cfc (diff)
downloadpugl-0f68cd00eb06ca1d7a4bdbb9e94ec060e784bd50.tar.gz
pugl-0f68cd00eb06ca1d7a4bdbb9e94ec060e784bd50.tar.bz2
pugl-0f68cd00eb06ca1d7a4bdbb9e94ec060e784bd50.zip
X11: Avoid potentially unnecessary allocation in Vulkan backend
Diffstat (limited to 'src')
-rw-r--r--src/x11_vulkan.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/x11_vulkan.c b/src/x11_vulkan.c
index 72ff701..5b6745e 100644
--- a/src/x11_vulkan.c
+++ b/src/x11_vulkan.c
@@ -28,19 +28,23 @@ struct PuglVulkanLoaderImpl {
PuglVulkanLoader*
puglNewVulkanLoader(PuglWorld* PUGL_UNUSED(world))
{
+ void* const libvulkan = dlopen("libvulkan.so", RTLD_LAZY);
+ if (!libvulkan) {
+ return NULL;
+ }
+
PuglVulkanLoader* const loader =
(PuglVulkanLoader*)calloc(1, sizeof(PuglVulkanLoader));
- if (!loader || !(loader->libvulkan = dlopen("libvulkan.so", RTLD_LAZY))) {
- free(loader);
- return NULL;
- }
+ if (loader) {
+ loader->libvulkan = libvulkan;
- loader->vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)dlsym(
- loader->libvulkan, "vkGetInstanceProcAddr");
+ loader->vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)dlsym(
+ loader->libvulkan, "vkGetInstanceProcAddr");
- loader->vkGetDeviceProcAddr =
- (PFN_vkGetDeviceProcAddr)dlsym(loader->libvulkan, "vkGetDeviceProcAddr");
+ loader->vkGetDeviceProcAddr =
+ (PFN_vkGetDeviceProcAddr)dlsym(loader->libvulkan, "vkGetDeviceProcAddr");
+ }
return loader;
}