diff options
| author | Christian Walther <cwalther@gmx.ch> | 2020-10-02 23:07:07 +0200 |
|---|---|---|
| committer | Christian Walther <cwalther@gmx.ch> | 2020-10-02 23:07:07 +0200 |
| commit | be8092f4d32d06488df88294a9dc4bb809411c5e (patch) | |
| tree | 8ea423247fdcf8487ef63981a8de54e6a2a9253d /supervisor/shared | |
| parent | 5bdb8c45dd2700941ab75661b773680bdd46aaf1 (diff) | |
When there is not enough free space, but a matching hole on the other side, use it.
Diffstat (limited to 'supervisor/shared')
| -rwxr-xr-x | supervisor/shared/memory.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/supervisor/shared/memory.c b/supervisor/shared/memory.c index fdb4e06fb..0f96ae273 100755 --- a/supervisor/shared/memory.c +++ b/supervisor/shared/memory.c @@ -125,7 +125,7 @@ supervisor_allocation* allocate_memory(uint32_t length, bool high) { supervisor_allocation* alloc; for (; index < CIRCUITPY_SUPERVISOR_ALLOC_COUNT; index += direction) { alloc = &allocations[index]; - if (alloc->length == FREE) { + if (alloc->length == FREE && (high_address - low_address) * 4 >= (int32_t) length) { break; } // If a hole matches in length exactly, we can reuse it. @@ -134,7 +134,7 @@ supervisor_allocation* allocate_memory(uint32_t length, bool high) { return alloc; } } - if (index >= CIRCUITPY_SUPERVISOR_ALLOC_COUNT || (high_address - low_address) * 4 < (int32_t) length) { + if (index >= CIRCUITPY_SUPERVISOR_ALLOC_COUNT) { return NULL; } if (high) { |
