From 05fd5c16eb8f963a16dde55774a32464275730b8 Mon Sep 17 00:00:00 2001 From: Joakim Gebart Date: Tue, 4 Aug 2015 21:05:08 +0200 Subject: [PATCH] sys/newlib/syscalls.c: Clean up _sbrk_r implementation --- sys/newlib/syscalls.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/sys/newlib/syscalls.c b/sys/newlib/syscalls.c index 8486b61f0e..28ab23c03b 100644 --- a/sys/newlib/syscalls.c +++ b/sys/newlib/syscalls.c @@ -43,7 +43,7 @@ */ extern char _sheap; /* start of the heap */ extern char _eheap; /* end of the heap */ -caddr_t heap_top = (caddr_t)&_sheap + 4; +char *heap_top = &_sheap + 4; /** * @brief Initialize NewLib, called by __libc_init_array() from the startup script @@ -85,15 +85,14 @@ void _exit(int n) * * @return [description] */ -caddr_t _sbrk_r(struct _reent *r, ptrdiff_t incr) +void *_sbrk_r(struct _reent *r, ptrdiff_t incr) { unsigned int state = disableIRQ(); - caddr_t res = heap_top; + void *res = heap_top; - if (((incr > 0) && ((heap_top + incr > &_eheap) || (heap_top + incr < res))) || - ((incr < 0) && ((heap_top + incr < &_sheap) || (heap_top + incr > res)))) { + if ((heap_top + incr > &_eheap) || (heap_top + incr < &_sheap)) { r->_errno = ENOMEM; - res = (void *) -1; + res = (void *)-1; } else { heap_top += incr;