summaryrefslogtreecommitdiff
path: root/src/malloc.c
diff options
context:
space:
mode:
authorPikalaxALT <pikalaxalt@gmail.com>2017-09-19 20:54:49 -0400
committerPikalaxALT <pikalaxalt@gmail.com>2017-09-19 20:54:49 -0400
commitd4d8f876e55f5dd1df792e0124d9fb488976151a (patch)
tree94664c7d3241b52aee3f08496f8f234eb3b3dc82 /src/malloc.c
parentbff89725ec31f87c296ec45f107f81dfe3cd54d6 (diff)
parentf94074b6027d1efe067fd972127eb7730cbef2e0 (diff)
Merge branch 'master' into battle_dome_cards
Diffstat (limited to 'src/malloc.c')
-rw-r--r--src/malloc.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/malloc.c b/src/malloc.c
index 3901c5a35..ccb2f7d20 100644
--- a/src/malloc.c
+++ b/src/malloc.c
@@ -38,7 +38,7 @@ void PutMemBlockHeader(void *block, struct MemBlock *prev, struct MemBlock *next
void PutFirstMemBlockHeader(void *block, u32 size)
{
- PutMemBlockHeader(block, (struct MemBlock *)block, (struct MemBlock *)block, size - 16);
+ PutMemBlockHeader(block, (struct MemBlock *)block, (struct MemBlock *)block, size - sizeof(struct MemBlock));
}
void *AllocInternal(void *heapStart, u32 size)
@@ -48,6 +48,7 @@ void *AllocInternal(void *heapStart, u32 size)
struct MemBlock *splitBlock;
u32 foundBlockSize;
+ // Alignment
if (size & 3)
size = 4 * ((size / 4) + 1);
@@ -58,7 +59,7 @@ void *AllocInternal(void *heapStart, u32 size)
foundBlockSize = pos->size;
if (foundBlockSize >= size) {
- if (foundBlockSize - size <= 31) {
+ if (foundBlockSize - size < 2 * sizeof(struct MemBlock)) {
// The block isn't much bigger than the requested size,
// so just use it.
pos->flag = TRUE;