From: ceriel Date: Wed, 19 Aug 1987 14:44:54 +0000 (+0000) Subject: fixed bugs in tzset and ttyslot, adapted malloc to allocate in bigger chunks X-Git-Tag: release-5-5~3882 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=cc524c3d9a0e807950e5363e2a62c989930eb818;p=ack.git fixed bugs in tzset and ttyslot, adapted malloc to allocate in bigger chunks --- diff --git a/lang/cem/libcc/gen/malloc.c b/lang/cem/libcc/gen/malloc.c index dbb534c68..9fc97f6ac 100644 --- a/lang/cem/libcc/gen/malloc.c +++ b/lang/cem/libcc/gen/malloc.c @@ -1,6 +1,6 @@ /* $Header$ */ -#define CLICK_SIZE 16 +#define CLICK_SIZE 4096 #if EM_WSIZE == EM_PSIZE typedef unsigned int vir_bytes; #else @@ -13,7 +13,7 @@ extern bcopy(); #define NEXT(p) (* (char **) (p)) #ifdef pdp -#define BUGFIX 64 +#define BUGFIX 64 /* cannot set break in top 64 bytes */ #else #define BUGFIX 0 #endif @@ -25,11 +25,15 @@ static grow(len) unsigned len; { register char *p; + register int click = CLICK_SIZE; - p = (char *) ALIGN((vir_bytes) top + sizeof(char *) + len, CLICK_SIZE) + while (click >= 4) { + p = (char *) ALIGN((vir_bytes) top + sizeof(char *) + len, click) + BUGFIX; - if (p < top || brk(p - BUGFIX) < 0) - return(0); + if (p > top && brk(p - BUGFIX) >= 0) break; + click >>= 1; + } + if (click < 4) return(0); top = p - (BUGFIX + sizeof(char *)); for (p = bottom; NEXT(p) != 0; p = (char *) (* (vir_bytes *) p & ~BUSY)) ; diff --git a/lang/cem/libcc/gen/ttyslot.c b/lang/cem/libcc/gen/ttyslot.c index 4a468b75c..9831db613 100644 --- a/lang/cem/libcc/gen/ttyslot.c +++ b/lang/cem/libcc/gen/ttyslot.c @@ -60,13 +60,14 @@ ttyslot() #else for (;;) { tp = buf; - for (;;) { + for (;;tp++) { if (read(fd, tp, 1) != 1) { close(fd); return 0; } if (*tp == '\n' || tp >= &buf[31]) { *tp = 0; + if (tp < buf+2) buf[2] = '\0'; tp = buf+2; break; } diff --git a/lang/cem/libcc/gen/tzset.c b/lang/cem/libcc/gen/tzset.c index ade2fedb5..5fb3e80ff 100644 --- a/lang/cem/libcc/gen/tzset.c +++ b/lang/cem/libcc/gen/tzset.c @@ -57,7 +57,6 @@ tzset() int sign = 1; strncpy(__tzname[0], p, 3); - p += 3; if (*(p += 3) == '-') { sign = -1; p++;