summaryrefslogtreecommitdiff
path: root/src/malloc.c
diff options
context:
space:
mode:
authorU-User-PC\User <golemgalvanize@github.com>2017-10-03 15:54:19 -0400
committerU-User-PC\User <golemgalvanize@github.com>2017-10-03 15:54:19 -0400
commit1ae3d9b57b0f4ad506a1bd7323e46d2fa768b6b7 (patch)
treefca8b14b2e5e3a2390c1b890db2f56f6f8cff744 /src/malloc.c
parent0a88d1042a80bcc703d05f1cf19527272424a03f (diff)
parentd32ec8bf7246468625ab68a2d62835d70b7ac98c (diff)
I hope this fixes merge conflicts
Diffstat (limited to 'src/malloc.c')
-rw-r--r--src/malloc.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/malloc.c b/src/malloc.c
index 3901c5a35..1d64351c3 100644
--- a/src/malloc.c
+++ b/src/malloc.c
@@ -2,6 +2,7 @@
static void *sHeapStart;
static u32 sHeapSize;
+static u32 malloc_c_unused_0300000c; // needed to align dma3_manager.o(.bss)
#define MALLOC_SYSTEM_ID 0xA3A3
@@ -38,7 +39,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 +49,7 @@ void *AllocInternal(void *heapStart, u32 size)
struct MemBlock *splitBlock;
u32 foundBlockSize;
+ // Alignment
if (size & 3)
size = 4 * ((size / 4) + 1);
@@ -58,7 +60,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;