fixed bugs in tzset and ttyslot, adapted malloc to allocate in bigger chunks
authorceriel <none@none>
Wed, 19 Aug 1987 14:44:54 +0000 (14:44 +0000)
committerceriel <none@none>
Wed, 19 Aug 1987 14:44:54 +0000 (14:44 +0000)
lang/cem/libcc/gen/malloc.c
lang/cem/libcc/gen/ttyslot.c
lang/cem/libcc/gen/tzset.c

index dbb534c..9fc97f6 100644 (file)
@@ -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))
        ;
index 4a468b7..9831db6 100644 (file)
@@ -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;
                        }
index ade2fed..5fb3e80 100644 (file)
@@ -57,7 +57,6 @@ tzset()
                int sign = 1;
 
                strncpy(__tzname[0], p, 3);
-               p += 3;
                if (*(p += 3) == '-') {
                        sign = -1;
                        p++;