diff options
author | PikalaxALT <pikalaxalt@gmail.com> | 2017-09-19 20:55:05 -0400 |
---|---|---|
committer | PikalaxALT <pikalaxalt@gmail.com> | 2017-09-19 20:55:05 -0400 |
commit | 2c07b94e94115d89aec51cd6fd0600ce73fbb675 (patch) | |
tree | efca127a29d73451e42898ce4fb016fd6e9e4c83 /src/malloc.c | |
parent | 60f8369a898a121691c1e29ea5235407ac282f49 (diff) | |
parent | f94074b6027d1efe067fd972127eb7730cbef2e0 (diff) |
Merge branch 'master' into berry_fix_program
Diffstat (limited to 'src/malloc.c')
-rw-r--r-- | src/malloc.c | 5 |
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; |