mirror of
https://github.com/RGBCube/serenity
synced 2025-05-24 06:05:08 +00:00
LibC: realloc() should reuse the existing allocation more often.
We were only reusing the existing allocation if the new requested size was exactly the same as the fudged size of the block. This meant that realloc() could allocate a new block even though the new block would be identical to the old block.
This commit is contained in:
parent
1c4882892c
commit
6785250f8c
1 changed files with 1 additions and 1 deletions
|
@ -287,7 +287,7 @@ void* realloc(void* ptr, size_t size)
|
|||
auto* header = (const CommonHeader*)page_base;
|
||||
old_size = header->m_size;
|
||||
|
||||
if (size == old_size)
|
||||
if (malloc_good_size(size) == old_size)
|
||||
return ptr;
|
||||
auto* new_ptr = malloc(size);
|
||||
memcpy(new_ptr, ptr, min(old_size, size));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue