diff options
| author | Mike Stroyan <mike@LunarG.com> | 2015-10-06 15:32:56 -0600 |
|---|---|---|
| committer | Mike Stroyan <mike@LunarG.com> | 2015-10-06 16:39:11 -0600 |
| commit | 6c223728323faa4a1307bd25ee7f0651c7590c05 (patch) | |
| tree | 2afd993e8032e4dc62718d197772fb9643e37b8f | |
| parent | a91d5a17aa5c68d5f9212ab47b5103378cc3de73 (diff) | |
| download | usermoji-6c223728323faa4a1307bd25ee7f0651c7590c05.tar.xz | |
loader, icd: correct use of _aligned_malloc
Memory allocated with _aligned_malloc on WIN32 should be released with _aligned_free.
If icd/common/icd-instance is ever used on WIN32 it will now use _aligned_free.
loader_aligned_heap_alloc and loader_aligned_alloc would require additional
matching loader_aligned*_free functions to be correct for WIN32.
But both functions are never used. Just remove those functions for now.
| -rw-r--r-- | icd/common/icd-instance.c | 4 | ||||
| -rw-r--r-- | loader/loader.c | 16 | ||||
| -rw-r--r-- | loader/loader.h | 6 | ||||
| -rw-r--r-- | loader/vk_loader_platform.h | 2 |
4 files changed, 4 insertions, 24 deletions
diff --git a/icd/common/icd-instance.c b/icd/common/icd-instance.c index 3568b763..b7920486 100644 --- a/icd/common/icd-instance.c +++ b/icd/common/icd-instance.c @@ -58,7 +58,11 @@ static void * VKAPI default_alloc(void *user_data, size_t size, static void VKAPI default_free(void *user_data, void *ptr) { +#if defined(_WIN32) + _aligned_free(ptr); +#else free(ptr); +#endif } struct icd_instance *icd_instance_create(const VkApplicationInfo *app_info, diff --git a/loader/loader.c b/loader/loader.c index 9b9455cb..1ffcc687 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -118,22 +118,6 @@ void* loader_heap_alloc( return malloc(size); } -void* loader_aligned_heap_alloc( - const struct loader_instance *instance, - size_t size, - size_t alignment, - VkSystemAllocType alloc_type) -{ - if (instance && instance->alloc_callbacks.pfnAlloc) { - return instance->alloc_callbacks.pfnAlloc(instance->alloc_callbacks.pUserData, size, alignment, alloc_type); - } -#if defined(_WIN32) - return _aligned_malloc(alignment, size); -#else - return aligned_alloc(alignment, size); -#endif -} - void loader_heap_free( const struct loader_instance *instance, void *pMem) diff --git a/loader/loader.h b/loader/loader.h index e27f18cb..e96df3e9 100644 --- a/loader/loader.h +++ b/loader/loader.h @@ -394,12 +394,6 @@ void* loader_heap_alloc( size_t size, VkSystemAllocType allocType); -void* loader_aligned_heap_alloc( - const struct loader_instance *instance, - size_t size, - size_t alignment, - VkSystemAllocType allocType); - void loader_heap_free( const struct loader_instance *instance, void *pMem); diff --git a/loader/vk_loader_platform.h b/loader/vk_loader_platform.h index 96021561..dd870ddd 100644 --- a/loader/vk_loader_platform.h +++ b/loader/vk_loader_platform.h @@ -203,7 +203,6 @@ static inline void loader_platform_thread_cond_broadcast(loader_platform_thread_ } #define loader_stack_alloc(size) alloca(size) -static inline void *loader_aligned_alloc(size_t alignment, size_t size) { void *ptr; posix_memalign(&ptr, alignment, size); return ptr; } #elif defined(_WIN32) // defined(__linux__) /* Windows-specific common code: */ @@ -448,7 +447,6 @@ char *loader_get_registry_string(const HKEY hive, #define DeleteCriticalSection PLEASE USE THE loader_platform_thread_delete_mutex() FUNCTION #define loader_stack_alloc(size) _alloca(size) -static inline void *loader_aligned_alloc(size_t alignment, size_t size) { return _aligned_malloc(alignment, size); } #endif // defined(_WIN32) #endif /* LOADER_PLATFORM_H_TEMP */ |
