Skip to content

Commit

Permalink
zmalloc: switch back to slower fit first alloc at the beginning of block
Browse files Browse the repository at this point in the history
because it has less memory fragmentation and is able to load ls.asm with
pound. faster alloc gave out-of-memory, with 30kB free - 10kB
application, should be able to fit 10kB source code(!).
  • Loading branch information
ivop committed Sep 11, 2024
1 parent b31138c commit 7f681c3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/zmalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void *zmalloc(size_t size) {
if (!p) return NULL;

if (p->size - size > block_info_size) {
#if 0
#if 1
// split, alloc at begin
struct block_info *q = (void *) p + block_info_size + size;
q->next = p->next;
Expand All @@ -71,7 +71,7 @@ void *zmalloc(size_t size) {
p->size = size;
q->free = 1;
#endif
#if 1
#if 0
// split, alloc at end
struct block_info *q = (void *) p + p->size - size;
p->size -= size + block_info_size;
Expand Down

0 comments on commit 7f681c3

Please sign in to comment.