Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/KhronosGroup/Vulkan-Loader.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Giessen <charles@lunarg.com>2022-05-21 04:38:05 +0300
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>2022-05-24 23:18:26 +0300
commit0a2395df92309cb0a4bf20ca3a7185ab658b0f31 (patch)
treec0187a65f89b9600b05e561215e48e75b7140809
parente65a8bcaeb8f1405c08463da88e8137fd87b7c3a (diff)
Use VkAllocationCallbacks in windows dirent
Pass the allocation callbacks directly to dirent_on_windows. This removes a unecessary dependency between the loader headers and dirent_on_windows.
-rw-r--r--loader/dirent_on_windows.c22
-rw-r--r--loader/dirent_on_windows.h8
-rw-r--r--loader/loader.c5
3 files changed, 16 insertions, 19 deletions
diff --git a/loader/dirent_on_windows.c b/loader/dirent_on_windows.c
index 183bb0a54..779291aae 100644
--- a/loader/dirent_on_windows.c
+++ b/loader/dirent_on_windows.c
@@ -15,8 +15,6 @@
#include <string.h>
#include "allocation.h"
-#include "loader.h"
-#include "vk_loader_platform.h"
#ifdef __cplusplus
extern "C" {
@@ -31,7 +29,7 @@ struct DIR {
char *name; /* null-terminated char string */
};
-DIR *opendir(const struct loader_instance *instance, const char *name) {
+DIR *opendir(const VkAllocationCallbacks *pAllocator, const char *name) {
DIR *dir = 0;
if (name && name[0]) {
@@ -39,22 +37,22 @@ DIR *opendir(const struct loader_instance *instance, const char *name) {
const char *all = /* search pattern must end with suitable wildcard */
strchr("/\\", name[base_length - 1]) ? "*" : "/*";
- if ((dir = (DIR *)loader_instance_heap_alloc(instance, sizeof *dir, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND)) != 0 &&
- (dir->name = (char *)loader_instance_heap_alloc(instance, base_length + strlen(all) + 1,
- VK_SYSTEM_ALLOCATION_SCOPE_COMMAND)) != 0) {
+ if ((dir = (DIR *)loader_alloc(pAllocator, sizeof *dir, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND)) != 0 &&
+ (dir->name = (char *)loader_alloc(pAllocator, base_length + strlen(all) + 1, VK_SYSTEM_ALLOCATION_SCOPE_COMMAND)) !=
+ 0) {
strcat(strcpy(dir->name, name), all);
if ((dir->handle = (handle_type)_findfirst(dir->name, &dir->info)) != -1) {
dir->result.d_name = 0;
} else /* rollback */
{
- loader_instance_heap_free(instance, dir->name);
- loader_instance_heap_free(instance, dir);
+ loader_free(pAllocator, dir->name);
+ loader_free(pAllocator, dir);
dir = 0;
}
} else /* rollback */
{
- loader_instance_heap_free(instance, dir);
+ loader_free(pAllocator, dir);
dir = 0;
errno = ENOMEM;
}
@@ -65,7 +63,7 @@ DIR *opendir(const struct loader_instance *instance, const char *name) {
return dir;
}
-int closedir(const struct loader_instance *instance, DIR *dir) {
+int closedir(const VkAllocationCallbacks *pAllocator, DIR *dir) {
int result = -1;
if (dir) {
@@ -73,8 +71,8 @@ int closedir(const struct loader_instance *instance, DIR *dir) {
result = _findclose(dir->handle);
}
- loader_instance_heap_free(instance, dir->name);
- loader_instance_heap_free(instance, dir);
+ loader_free(pAllocator, dir->name);
+ loader_free(pAllocator, dir);
}
if (result == -1) /* map all errors to EBADF */
diff --git a/loader/dirent_on_windows.h b/loader/dirent_on_windows.h
index f4e2c242b..d11a2d468 100644
--- a/loader/dirent_on_windows.h
+++ b/loader/dirent_on_windows.h
@@ -10,7 +10,7 @@
*/
-#include "loader_common.h"
+#include <vulkan/vulkan.h>
#ifdef __cplusplus
extern "C" {
@@ -22,9 +22,9 @@ struct dirent {
char *d_name;
};
-// pass in loader_instance to allow allocation callback usage
-DIR *opendir(const struct loader_instance *instance, const char *);
-int closedir(const struct loader_instance *instance, DIR *);
+// pass in VkAllocationCallbacks to allow allocation callback usage
+DIR *opendir(const VkAllocationCallbacks *pAllocator, const char *);
+int closedir(const VkAllocationCallbacks *pAllocator, DIR *);
struct dirent *readdir(DIR *);
void rewinddir(DIR *);
diff --git a/loader/loader.c b/loader/loader.c
index 597689f28..c494c22a1 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -131,15 +131,14 @@ bool loader_check_version_meets_required(loader_api_version required, loader_api
// while linux opendir & readdir does not
DIR *loader_opendir(const struct loader_instance *instance, const char *name) {
#if defined(_WIN32)
- return opendir(instance, name);
+ return opendir(instance ? &instance->alloc_callbacks : NULL, name);
#else // _WIN32
return opendir(name);
-
#endif // _WIN32
}
int loader_closedir(const struct loader_instance *instance, DIR *dir) {
#if defined(_WIN32)
- return closedir(instance, dir);
+ return closedir(instance ? &instance->alloc_callbacks : NULL, dir);
#else // _WIN32
return closedir(dir);
#endif // _WIN32