From bdae1d3b79748a018c87b3e029d5bacf81e41d5d Mon Sep 17 00:00:00 2001 From: dragonmux Date: Fri, 31 May 2024 17:19:43 +0100 Subject: [PATCH] common/syscalls: Simplified the heap_current initial state logic --- src/platforms/common/syscalls.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/platforms/common/syscalls.c b/src/platforms/common/syscalls.c index 49cb9d85001..823f4fdcf85 100644 --- a/src/platforms/common/syscalls.c +++ b/src/platforms/common/syscalls.c @@ -31,7 +31,7 @@ typedef struct stat stat_s; extern uint8_t heap_start; extern uint8_t heap_end; -static uint8_t *heap_current = NULL; +static uint8_t *heap_current = &heap_start; #if ENABLE_DEBUG == 1 /* @@ -172,10 +172,6 @@ __attribute__((used)) int _kill(const int pid, const int signal) __attribute__((used)) void *_sbrk(const ptrdiff_t alloc_size) { - /* If we've not yet made any heap allocations, set the heap pointer up */ - if (heap_current == NULL) - heap_current = &heap_start; - /* Check if this allocation would exhaust the heap */ if (heap_current + alloc_size > &heap_end) { errno = ENOMEM;