Skip to content

Commit

Permalink
common/syscalls: Simplified the heap_current initial state logic
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonmux committed Jun 2, 2024
1 parent 7c01204 commit bdae1d3
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/platforms/common/syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
/*
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit bdae1d3

Please sign in to comment.