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)