summaryrefslogtreecommitdiffstats
path: root/src/rw
diff options
context:
space:
mode:
authoraap <aap@papnet.eu>2020-05-16 14:34:51 +0200
committeraap <aap@papnet.eu>2020-05-16 14:34:51 +0200
commitc54d3ba2ab218b9545e784abaf39b4054d3de4bc (patch)
treee9801a3f0afbae2bf9dbb3a93fe6b3790e1e1dfc /src/rw
parentfixed CText to be 64 bit compatible (diff)
downloadre3-c54d3ba2ab218b9545e784abaf39b4054d3de4bc.tar
re3-c54d3ba2ab218b9545e784abaf39b4054d3de4bc.tar.gz
re3-c54d3ba2ab218b9545e784abaf39b4054d3de4bc.tar.bz2
re3-c54d3ba2ab218b9545e784abaf39b4054d3de4bc.tar.lz
re3-c54d3ba2ab218b9545e784abaf39b4054d3de4bc.tar.xz
re3-c54d3ba2ab218b9545e784abaf39b4054d3de4bc.tar.zst
re3-c54d3ba2ab218b9545e784abaf39b4054d3de4bc.zip
Diffstat (limited to '')
-rw-r--r--src/rw/RwHelper.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/rw/RwHelper.cpp b/src/rw/RwHelper.cpp
index 5026e2c8..191fc7ab 100644
--- a/src/rw/RwHelper.cpp
+++ b/src/rw/RwHelper.cpp
@@ -59,6 +59,16 @@ void FlushObrsPrintfs()
void *
RwMallocAlign(RwUInt32 size, RwUInt32 align)
{
+#ifdef FIX_BUGS
+ uintptr ptralign = align-1;
+ void *mem = (void *)malloc(size + sizeof(uintptr) + ptralign);
+
+ ASSERT(mem != nil);
+
+ void *addr = (void *)((((uintptr)mem) + sizeof(uintptr) + ptralign) & ~ptralign);
+
+ ASSERT(addr != nil);
+#else
void *mem = (void *)malloc(size + align);
ASSERT(mem != nil);
@@ -66,6 +76,7 @@ RwMallocAlign(RwUInt32 size, RwUInt32 align)
void *addr = (void *)((((uintptr)mem) + align) & ~(align - 1));
ASSERT(addr != nil);
+#endif
*(((void **)addr) - 1) = mem;