class: ExternalBytes
comment/format in:
#new:
#unprotectFromGC
#unprotectedNew:
--- a/ExternalBytes.st Wed Jun 12 10:37:20 2013 +0200
+++ b/ExternalBytes.st Fri Jun 14 14:37:48 2013 +0200
@@ -409,7 +409,7 @@
new:numberOfBytes
"allocate some memory usable for data;
- the memory is not controlled by the garbage collector.
+ the memory safe from being finalized by the garbage collector.
Return a corresponding ExternalBytes object or raise MallocFailure (if malloc fails).
Use this, if you have to pass a block of bytes to some
@@ -420,8 +420,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|
@@ -448,14 +448,15 @@
unprotectedNew:numberOfBytes
"allocate some memory usable for data;
- the memory is under the control of the garbage collector.
+ the memory is under the control of the garbage collector (i.e. the instance will
+ be finalized and the malloc'd memory will be freed, if the instance goes away).
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|
@@ -1247,6 +1248,7 @@
unprotectFromGC
"remove the receiver from the AllocatedInstances
class variable - if there is no other reference to the receiver,
+ and this was ever allocated by me (i.e. not by the outside world),
the next garbage collect will finalize the receiver and the underlying
memory be freed."
@@ -1258,7 +1260,7 @@
wasBlocked := OperatingSystem blockInterrupts.
"/ AccessLock critical:[
AllocatedInstances notNil ifTrue:[
- AllocatedInstances remove:self ifAbsent:nil.
+ AllocatedInstances remove:self ifAbsent:nil.
].
"/ ]
wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
@@ -1316,11 +1318,11 @@
!ExternalBytes class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/ExternalBytes.st,v 1.89 2013-05-21 20:44:47 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/ExternalBytes.st,v 1.90 2013-06-14 12:37:48 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/ExternalBytes.st,v 1.89 2013-05-21 20:44:47 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/ExternalBytes.st,v 1.90 2013-06-14 12:37:48 cg Exp $'
! !