mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Fix suboptimal heap chunk spliting.
This commit is contained in:
parent
4283d90102
commit
73cea916d9
1 changed files with 4 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
|||
/*******************************************************************************
|
||||
|
||||
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013.
|
||||
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013, 2014.
|
||||
|
||||
This file is part of the Sortix C Library.
|
||||
|
||||
|
@ -493,9 +493,10 @@ extern "C" void* malloc(size_t size)
|
|||
assert(!bins[binindex] || bins[binindex]->IsSane());
|
||||
|
||||
// If we don't use the entire chunk.
|
||||
if ( OVERHEAD <= binsize - size )
|
||||
size_t original_chunk_size = chunk->size;
|
||||
if ( OVERHEAD <= original_chunk_size - size )
|
||||
{
|
||||
size_t left = binsize - size;
|
||||
size_t left = original_chunk_size - size;
|
||||
chunk->size -= left;
|
||||
chunk->GetTrailer()->size = chunk->size;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue