ExternalBytes.st
changeset 18653 51b75b45b563
parent 18607 90941e1c74c8
child 18678 a9b30d72dff9
child 18829 1f56d744775b
--- a/ExternalBytes.st	Mon Aug 03 12:01:36 2015 +0200
+++ b/ExternalBytes.st	Mon Aug 03 12:02:00 2015 +0200
@@ -142,6 +142,7 @@
 	return newPtr;
 }
 
+void
 __stx_free(ptr)
     char *ptr;
 {
@@ -153,6 +154,7 @@
 	free(ptr);
 }
 
+void
 __stx_mallocStatistics() {
 	struct mallocList *this;
 	int amount = 0;
@@ -422,8 +424,8 @@
      may change their address.
 
      DANGER ALERT: the memory is NOT automatically freed until it is either
-                   MANUALLY freed (see #free) or the returned externalBytes object
-                   is unprotected or the classes releaseAllMemory method is called."
+		   MANUALLY freed (see #free) or the returned externalBytes object
+		   is unprotected or the classes releaseAllMemory method is called."
 
     |newInst|
 
@@ -455,10 +457,10 @@
      Return a corresponding ExternalBytes object or raise MallocFailure (if malloc fails).
 
      DANGER ALERT: the memory block as allocated will be automatically freed
-                   as soon as the reference to the returned externalBytes object
-                   is gone (by the next garbage collect).
-                   If the memory has been passed to a C-function which
-                   remembers this pointer, bad things may happen ...."
+		   as soon as the reference to the returned externalBytes object
+		   is gone (by the next garbage collect).
+		   If the memory has been passed to a C-function which
+		   remembers this pointer, bad things may happen ...."
 
     |newInst|
 
@@ -568,8 +570,8 @@
 
 %{  /* NOCONTEXT */
     struct {
-        char c;
-        double d;
+	char c;
+	double d;
     } dummy;
     RETURN (__mkSmallInteger( (char *)&dummy.d - (char *)&dummy.c ));
 %}
@@ -592,8 +594,8 @@
 
 %{  /* NOCONTEXT */
     struct {
-        char c;
-        long l;
+	char c;
+	long l;
     } dummy;
     RETURN (__mkSmallInteger( (char *)&dummy.l - (char *)&dummy.c ));
 %}
@@ -658,7 +660,7 @@
     ^ nil
 
     "
-     ExternalBytes sizeofLongDouble 
+     ExternalBytes sizeofLongDouble
     "
 !
 
@@ -1151,24 +1153,24 @@
     "/ what a kludge - Dolphin and Squeak mean: printOn: a stream;
     "/ ST/X (and some old ST80's) mean: draw-yourself on a GC.
     (aGCOrStream isStream) ifFalse:[
-        ^ super displayOn:aGCOrStream
+	^ super displayOn:aGCOrStream
     ].
 
     aGCOrStream nextPutAll:self className.
     addr := self address.
     addr isNil ifTrue:[
-        aGCOrStream nextPutAll:'[free]'.
+	aGCOrStream nextPutAll:'[free]'.
     ] ifFalse:[
-        size notNil ifTrue:[
-            aGCOrStream nextPutAll:'[sz:'.
-            size printOn:aGCOrStream.
-            aGCOrStream space.
-        ] ifFalse:[
-            aGCOrStream nextPut:$[.
-        ].
-        aGCOrStream nextPutAll:'at:'.
-        addr printOn:aGCOrStream base:16.
-        aGCOrStream nextPut:$].
+	size notNil ifTrue:[
+	    aGCOrStream nextPutAll:'[sz:'.
+	    size printOn:aGCOrStream.
+	    aGCOrStream space.
+	] ifFalse:[
+	    aGCOrStream nextPut:$[.
+	].
+	aGCOrStream nextPutAll:'at:'.
+	addr printOn:aGCOrStream base:16.
+	aGCOrStream nextPut:$].
     ].
 
     "Modified: / 24.2.2000 / 19:02:19 / cg"
@@ -1281,27 +1283,27 @@
      this should speedup class file reading considerably"
 
 %{  /* NOCONTEXT */
-    unsigned char *cp = __INST(address_);
+    unsigned char *cp = (unsigned char *)(__INST(address_));
     unsigned int size = __intVal(__INST(size));
     unsigned char *endP;
 
     if (cp == nil || size == 0) {
-        RETURN(false);
+	RETURN(false);
     }
 
     endP = cp + size;
 #if __POINTER_SIZE__ == 8
     while (cp+8 < endP) {
-        if ( ((unsigned INT *)cp)[0] & 0x8080808080808080) RETURN( true );
-        cp += 8;
+	if ( ((unsigned INT *)cp)[0] & 0x8080808080808080) RETURN( true );
+	cp += 8;
     }
 #endif
     while (cp+4 < endP) {
-        if ( ((unsigned int *)cp)[0] & 0x80808080) RETURN( true );
-        cp += 4;
+	if ( ((unsigned int *)cp)[0] & 0x80808080) RETURN( true );
+	cp += 4;
     }
     while (cp < endP) {
-        if (*cp++ & 0x80) RETURN( true );
+	if (*cp++ & 0x80) RETURN( true );
     }
     RETURN ( false );
 %}
@@ -1366,7 +1368,7 @@
     wasBlocked := OperatingSystem blockInterrupts.
 "/    AccessLock critical:[
     AllocatedInstances notNil ifTrue:[
-        AllocatedInstances remove:self ifAbsent:nil.
+	AllocatedInstances remove:self ifAbsent:nil.
     ].
 "/    ]
     wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
@@ -1388,32 +1390,32 @@
     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.
     ]].
 ! !