*** empty log message ***
authorClaus Gittinger <cg@exept.de>
Thu, 01 Apr 1999 12:28:25 +0200
changeset 4086 4b3a61a4e35d
parent 4085 0e67cf7e935b
child 4087 7d865b7352b0
*** empty log message ***
ByteArray.st
--- a/ByteArray.st	Thu Apr 01 11:13:27 1999 +0200
+++ b/ByteArray.st	Thu Apr 01 12:28:25 1999 +0200
@@ -965,7 +965,7 @@
     REGISTER unsigned char *endp;
     REGISTER int count;
     int len, index1, index2;
-    unsigned char s[1024], savec;
+    unsigned char scratchBuffer[1024], savec;
 
     if (__isByteArray(self) && __bothSmallInteger(start, stop)) {
         len = __byteArraySize(self);
@@ -981,13 +981,16 @@
                 savec = *endp;
                 *endp = '\0';
                 sym = __MKSYMBOL(srcp, 0);
+		/* must refetch endp (in case of a GC */
                 endp = __ByteArrayInstPtr(self)->ba_element + index1 + count;
                 *endp = savec;
-            } else if (count < sizeof(s)) {
+            } else {
                 /* not enough space for '\0', copy the bytes */
-                bcopy(srcp, s, count);
-                s[count] = '\0';
-                sym = __MKSYMBOL(s, 0);
+		if (count < sizeof(scratchBuffer)) {
+                    bcopy(srcp, scratchBuffer, count);
+                    scratchBuffer[count] = '\0';
+                    sym = __MKSYMBOL(scratchBuffer, 0);
+		}
             }
         }
         if (sym != nil)
@@ -996,8 +999,8 @@
 %}.
     "
      fall back in case of non-integer index or out-of-bound index
-     or no memory available;
-     will eventually lead to an out-of-bound signal raise
+     or not enough stack-memory available;
+     may eventually lead to an out-of-bound signal raise
     "
     ^ (super copyFrom:start to:stop) asString asSymbol
 
@@ -2077,5 +2080,5 @@
 !ByteArray class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ByteArray.st,v 1.104 1999-03-19 20:42:19 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ByteArray.st,v 1.106 1999-04-01 10:28:25 cg Exp $'
 ! !