#include <string.h>
#include "allocation.h"
-#include "loader.h"
-#include "vk_loader_platform.h"
#ifdef __cplusplus
extern "C" {
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]) {
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;
}
return dir;
}
-int closedir(const struct loader_instance *instance, DIR *dir) {
+int closedir(const VkAllocationCallbacks *pAllocator, DIR *dir) {
int result = -1;
if (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 */
*/
-#include "loader_common.h"
+#include <vulkan/vulkan.h>
#ifdef __cplusplus
extern "C" {
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 *);
// 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