summaryrefslogtreecommitdiffstats
path: root/src/rw/RwHelper.cpp
diff options
context:
space:
mode:
authorNikolay Korolev <nickvnuk@gmail.com>2020-05-16 22:09:34 +0200
committerNikolay Korolev <nickvnuk@gmail.com>2020-05-16 22:09:34 +0200
commit5c8888d2edb4f77a30ca52c5a48669d937ae9ef2 (patch)
tree62c1274fc38820d2f2037ae6dab48576439b1ed2 /src/rw/RwHelper.cpp
parentmore script stuff (diff)
parentMerge branch 'master' into miami (diff)
downloadre3-5c8888d2edb4f77a30ca52c5a48669d937ae9ef2.tar
re3-5c8888d2edb4f77a30ca52c5a48669d937ae9ef2.tar.gz
re3-5c8888d2edb4f77a30ca52c5a48669d937ae9ef2.tar.bz2
re3-5c8888d2edb4f77a30ca52c5a48669d937ae9ef2.tar.lz
re3-5c8888d2edb4f77a30ca52c5a48669d937ae9ef2.tar.xz
re3-5c8888d2edb4f77a30ca52c5a48669d937ae9ef2.tar.zst
re3-5c8888d2edb4f77a30ca52c5a48669d937ae9ef2.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 91916df3..a87874d7 100644
--- a/src/rw/RwHelper.cpp
+++ b/src/rw/RwHelper.cpp
@@ -60,6 +60,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);
@@ -67,6 +77,7 @@ RwMallocAlign(RwUInt32 size, RwUInt32 align)
void *addr = (void *)((((uintptr)mem) + align) & ~(align - 1));
ASSERT(addr != nil);
+#endif
*(((void **)addr) - 1) = mem;