diff options
| author | Jon Ashburn <jon@lunarg.com> | 2016-01-07 15:21:14 -0700 |
|---|---|---|
| committer | Jon Ashburn <jon@lunarg.com> | 2016-01-07 15:22:56 -0700 |
| commit | 465f5eefb1935edc6aef8dd6eba24e040d22f14f (patch) | |
| tree | d5fbc1e33bffe57155d382aae2281ad1b2d06499 /loader/loader.c | |
| parent | 0ed2bbf5ff017ad96fadf2b18dce08d13e04dd8b (diff) | |
| download | usermoji-465f5eefb1935edc6aef8dd6eba24e040d22f14f.tar.xz | |
misc: make sure host memory alignment is a power of two
Use sizeof(int) as a default generally. Is that reasonable?
Diffstat (limited to 'loader/loader.c')
| -rw-r--r-- | loader/loader.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/loader/loader.c b/loader/loader.c index 79ed84ba..81c805ab 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -152,7 +152,7 @@ void* loader_heap_alloc( { 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 @@ void* loader_heap_realloc( 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); |
