summaryrefslogtreecommitdiff
path: root/src/malloc.c
diff options
context:
space:
mode:
authorDizzyEggg <jajkodizzy@wp.pl>2017-09-23 20:36:00 +0200
committerDizzyEggg <jajkodizzy@wp.pl>2017-09-23 20:36:00 +0200
commit7bb0fcf182e5a760ab9e08878a381566819dc8f2 (patch)
treebbb0603d41fa6d0d71a838c7e2fde85fe346fbe1 /src/malloc.c
parent601fc9e85b383792819768c31728e4855e854f32 (diff)
parenta57915fa5bd8c2e68bc291a371e66e3cafd7e195 (diff)
merge with master and fix conflicts
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;