class: ExternalBytes
authorClaus Gittinger <cg@exept.de>
Wed, 09 Jul 2014 16:59:43 +0200
changeset 16705 2f799eb4276d
parent 16704 7c006f1bbb16
child 16706 f5d25a583a27
class: ExternalBytes changed: #grow: don't grow if the same size is requested
ExternalBytes.st
--- a/ExternalBytes.st	Wed Jul 09 16:52:32 2014 +0200
+++ b/ExternalBytes.st	Wed Jul 09 16:59:43 2014 +0200
@@ -1274,38 +1274,40 @@
 
     |mallocStatus|
 
+    size == numberOfBytes ifTrue:[^ self].
+
 %{
     char *space, *prevSpace;
     unsigned int nBytes;
     char *__stx_realloc();
 
     if (__isSmallInteger(numberOfBytes)) {
-	nBytes = __smallIntegerVal(numberOfBytes);
-	if (nBytes > 0) {
-	    prevSpace = (char *)__INST(address_);
-	    if (prevSpace == (char *)nil)
-		prevSpace = 0;  /* allocate from scratch */
-	    space = __stx_realloc(prevSpace, nBytes);
-	    if (space) {
-		__INST(address_) = (OBJ)space;
-		__INST(size) = numberOfBytes;
-		if (space == prevSpace) {
-		    /* same address, no re-registration */
-		    RETURN(self);
-		}
-		mallocStatus = true;
-	    } else {
-		mallocStatus = false;
-	    }
-	}
+        nBytes = __smallIntegerVal(numberOfBytes);
+        if (nBytes > 0) {
+            prevSpace = (char *)__INST(address_);
+            if (prevSpace == (char *)nil)
+                prevSpace = 0;  /* allocate from scratch */
+            space = __stx_realloc(prevSpace, nBytes);
+            if (space) {
+                __INST(address_) = (OBJ)space;
+                __INST(size) = numberOfBytes;
+                if (space == prevSpace) {
+                    /* same address, no re-registration */
+                    RETURN(self);
+                }
+                mallocStatus = true;
+            } else {
+                mallocStatus = false;
+            }
+        }
     }
 %}.
     mallocStatus == true ifTrue:[
-	Lobby registerChange:self.
+        Lobby registerChange:self.
     ] ifFalse:[mallocStatus == false ifTrue:[
-	^ MallocFailure raiseRequestWith:numberOfBytes.
+        ^ MallocFailure raiseRequestWith:numberOfBytes.
     ] ifFalse:[
-	self primitiveFailed.
+        self primitiveFailed.
     ]].
 ! !
 
@@ -1318,11 +1320,11 @@
 !ExternalBytes class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ExternalBytes.st,v 1.90 2013-06-14 12:37:48 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ExternalBytes.st,v 1.91 2014-07-09 14:59:43 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/ExternalBytes.st,v 1.90 2013-06-14 12:37:48 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ExternalBytes.st,v 1.91 2014-07-09 14:59:43 cg Exp $'
 ! !