misc: make sure host memory alignment is a power of two
Use sizeof(int) as a default generally. Is that reasonable?
diff --git a/loader/debug_report.c b/loader/debug_report.c
index ebb1ae2..4065fb0 100644
--- a/loader/debug_report.c
+++ b/loader/debug_report.c
@@ -74,7 +74,7 @@
{
VkLayerDbgFunctionNode *pNewDbgFuncNode;
if (pAllocator != NULL) {
- pNewDbgFuncNode = (VkLayerDbgFunctionNode *) pAllocator->pfnAllocation(pAllocator->pUserData, sizeof(VkLayerDbgFunctionNode), sizeof(uint32_t), VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
+ pNewDbgFuncNode = (VkLayerDbgFunctionNode *) pAllocator->pfnAllocation(pAllocator->pUserData, sizeof(VkLayerDbgFunctionNode), sizeof(int *), VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
} else {
pNewDbgFuncNode = (VkLayerDbgFunctionNode *) loader_heap_alloc(inst, sizeof(VkLayerDbgFunctionNode), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
}
diff --git a/loader/loader.c b/loader/loader.c
index 79ed84b..81c805a 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -152,7 +152,7 @@
{
if (instance && instance->alloc_callbacks.pfnAllocation) {
/* TODO: What should default alignment be? 1, 4, 8, other? */
- return instance->alloc_callbacks.pfnAllocation(instance->alloc_callbacks.pUserData, size, 4, alloc_scope);
+ return instance->alloc_callbacks.pfnAllocation(instance->alloc_callbacks.pUserData, size, sizeof(int), alloc_scope);
}
return malloc(size);
}
@@ -182,12 +182,14 @@
loader_heap_free(instance, pMemory);
return NULL;
}
+ //TODO use the callback realloc function
if (instance && instance->alloc_callbacks.pfnAllocation) {
if (size <= orig_size) {
memset(((uint8_t *)pMemory) + size, 0, orig_size - size);
return pMemory;
}
- void *new_ptr = instance->alloc_callbacks.pfnAllocation(instance->alloc_callbacks.pUserData, size, 4, alloc_scope);
+ /* TODO: What should default alignment be? 1, 4, 8, other? */
+ void *new_ptr = instance->alloc_callbacks.pfnAllocation(instance->alloc_callbacks.pUserData, size, sizeof(int), alloc_scope);
if (!new_ptr)
return NULL;
memcpy(new_ptr, pMemory, orig_size);
diff --git a/loader/trampoline.c b/loader/trampoline.c
index 6d68166..6a81caf 100644
--- a/loader/trampoline.c
+++ b/loader/trampoline.c
@@ -53,7 +53,7 @@
ptr_instance = (struct loader_instance *) pAllocator->pfnAllocation(
pAllocator->pUserData,
sizeof(struct loader_instance),
- sizeof(VkInstance),
+ sizeof(int *),
VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
} else {
ptr_instance = (struct loader_instance *) malloc(sizeof(struct loader_instance));