tkchia / newlib-ia16

Fork of IA-16 port of Newlib -- added small and medium model support
GNU General Public License v2.0
13 stars 4 forks source link

Nanomalloc improve last free chunk #11

Closed bartoldeman closed 5 years ago

bartoldeman commented 5 years ago

There are three commits in here:

  1. Cleanup to prep.
  2. If the chunk before sbrk(0) is free, extend it instead of creating a new chunk (which created two free chunks in sequence!)
  3. When splitting a chunk, return first chunk, second is free. This also helps if the chunk before sbrk(0) is free since it leaves more space at the end, rather then creating a hole there.

This helps FreeCOM memory consumption greatly, from needing a heap > 8K to needing one of just under 5K, while still using the simple "first fit" allocation strategy.