From bfe73f1886bd94c08a26def67cd72ba691ae134c Mon Sep 17 00:00:00 2001 From: Milang Date: Sat, 17 Aug 2019 18:23:41 +0200 Subject: [PATCH] align the buffer --- src/FxEngine/zbuffer.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/FxEngine/zbuffer.c b/src/FxEngine/zbuffer.c index 15a94f8..c6d2f7f 100644 --- a/src/FxEngine/zbuffer.c +++ b/src/FxEngine/zbuffer.c @@ -26,6 +26,20 @@ static const uint32_t size_char = size_uint32*sizeof(int32_t); static int32_t* address=0; const int32_t clearval=3000; + +#define ALIGN 4 +static void* buffer_malloc(uint32_t size) +{ + void *mem = malloc(size+ALIGN+sizeof(void*)); + void **ptr = (void**)((uintptr_t)(mem+ALIGN+sizeof(void*)) & ~(ALIGN-1)); + ptr[-1] = mem; + return ptr; +} +void aligned_free(void *ptr) +{ + free(((void**)ptr)[-1]); +} + void FE_zbuffer_clear() { if (address==0)