shithub: scc

Download patch

ref: 6ebdc448545eb48b37b63fed98c03e219b620c96
parent: 419ebc8cada738e12a89dfe4d47a414b7dde96f3
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Wed Dec 19 06:14:59 EST 2018

[libc] Fix malloc

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

--- 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 @@
 
 $(TARGET): objlst
 	xargs $(AR) $(ARFLAGS) $@ < objlst
+	$(RL) $(RANLIBFLAGS) $@
 
 clean:
 	$(FORALL)
--- a/src/libc/stdlib/malloc.c
+++ b/src/libc/stdlib/malloc.c
@@ -81,7 +81,7 @@
 		return ERRADDR;
 	new = old + inc;
 	p = _brk(new);
-	if (p == old || p < 0)
+	if (p == old || p == ERRADDR)
 		return ERRADDR;
 	heap = new;
 
--- 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 {