diff --git a/libs/scene/hierarchy.c b/libs/scene/hierarchy.c index 4573e9e6e..3aa758624 100644 --- a/libs/scene/hierarchy.c +++ b/libs/scene/hierarchy.c @@ -40,17 +40,6 @@ #include "scn_internal.h" -#if defined(_WIN32) && !defined(_WIN64) -// FIXME (maybe) this is a hack to make DARRAY arrrays 16-byte aligned on -// 32-bit systems (in particular for this case, windows) as the vectors and -// matrices require 16-byte alignment but system malloc (etc) provide only -// 8-byte alignment. -// Really, a custom allocator (maybe using cmem) would be better. -#define free(mem) _aligned_free(mem) -#define malloc(size) _aligned_malloc(size, 16) -#define realloc(mem, size) _aligned_realloc(mem, size, 16) -#endif - static void hierarchy_UpdateTransformIndices (hierarchy_t *hierarchy, uint32_t start, int offset) diff --git a/libs/util/sys.c b/libs/util/sys.c index bd985428f..43b3b1e05 100644 --- a/libs/util/sys.c +++ b/libs/util/sys.c @@ -646,6 +646,39 @@ Sys_PageIn (void *ptr, size_t size) //#endif } +#if defined(_WIN32) && !defined(_WIN64) +// this is a hack to make memory allocations 16-byte aligned on 32-bit +// systems (in particular for this case, windows) as vectors and +// matrices require 16-byte alignment but system malloc (etc) provide only +// 8-byte alignment. +void *__cdecl +calloc (size_t nume, size_t sizee) +{ + size_t size = nume * sizee; + void *mem = _aligned_malloc (size, 16); + memset (mem, 0, size); + return mem; +} + +void __cdecl +free (void *mem) +{ + _aligned_free (mem); +} + +void *__cdecl +malloc (size_t size) +{ + return _aligned_malloc (size, 16); +} + +void *__cdecl +realloc (void *mem, size_t size) +{ + return _aligned_realloc (mem, size, 16); +} +#endif + VISIBLE size_t Sys_PageSize (void) {