scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit 7203abbbf68f9bf1fd4aa51673f657e8da4c4fb0
parent 63f3628b766dd745aea8a1fe3900ce32a121c872
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed, 19 Dec 2018 11:14:59 +0000

[libc] Fix malloc

The number of units was to big, and the check for _brk was wrong.

Diffstat:
Msrc/libc/Makefile | 2+-
Msrc/libc/stdlib/malloc.c | 2+-
Msrc/libc/stdlib/malloc.h | 2+-
3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/libc/Makefile b/src/libc/Makefile @@ -1,5 +1,4 @@ .POSIX: - PROJECTDIR =../.. include $(PROJECTDIR)/scripts/rules.mk include rules.mk @@ -25,6 +24,7 @@ objlst: FORCE $(TARGET): objlst xargs $(AR) $(ARFLAGS) $@ < objlst + $(RL) $(RANLIBFLAGS) $@ clean: $(FORALL) diff --git a/src/libc/stdlib/malloc.c b/src/libc/stdlib/malloc.c @@ -81,7 +81,7 @@ sbrk(uintptr_t inc) return ERRADDR; new = old + inc; p = _brk(new); - if (p == old || p < 0) + if (p == old || p == ERRADDR) return ERRADDR; heap = new; diff --git a/src/libc/stdlib/malloc.h b/src/libc/stdlib/malloc.h @@ -1,7 +1,7 @@ #include <stdlib.h> /* minimum amount of required units */ -#define NALLOC 10000 +#define NALLOC 16 typedef union header Header; union header {