String.st
branchjv
changeset 17943 1d2620126660
parent 17939 9ea58e0aad5a
child 17944 084a2c804b87
--- a/String.st	Sun May 13 18:32:24 2012 +0100
+++ b/String.st	Tue Jun 05 13:18:28 2012 +0100
@@ -487,6 +487,8 @@
     ^ Character tab asString
 ! !
 
+
+
 !String class methodsFor:'queries'!
 
 defaultPlatformClass
@@ -506,6 +508,12 @@
     "Modified: 23.4.1996 / 16:00:38 / cg"
 ! !
 
+
+
+
+
+
+
 !String methodsFor:'Compatibility-VW5.4'!
 
 asGUID
@@ -699,6 +707,7 @@
     "
 ! !
 
+
 !String methodsFor:'character searching'!
 
 identityIndexOf:aCharacter
@@ -1915,6 +1924,31 @@
     "Modified: / 03-08-2006 / 14:45:32 / fm"
 !
 
+asExternalBytesUnprotected
+    "Like asExternalBytes, but does not register the bytes so
+     bytes are NOT GARBAGE-COLLECTED. You have to free then yourself!!!!!!
+
+     Use with care!!
+
+     "
+
+    |bytes sz|
+
+    sz := self byteSize.
+    bytes := ExternalBytes basicNew allocateBytes:sz.
+    bytes replaceFrom:1 to:sz with:self startingAt:1.
+    bytes at:(sz + 1) put:0.
+    ^ bytes
+
+    "
+     |x|
+     x := 'fooBar' asExternalBytesUnprotected.
+     ObjectMemory garbageCollect
+    "
+
+    "Created: / 05-06-2012 / 14:16:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 asImmutableString
     "return a write-protected copy of myself"
 
@@ -2605,6 +2639,7 @@
     ^ super simpleDeepCopy
 ! !
 
+
 !String methodsFor:'filling & replacing'!
 
 atAllPut:aCharacter
@@ -3275,6 +3310,7 @@
     ^ String
 ! !
 
+
 !String methodsFor:'sorting & reordering'!
 
 reverse
@@ -3305,6 +3341,7 @@
     ^ super reverse
 ! !
 
+
 !String methodsFor:'substring searching'!
 
 indexOfSubCollection:aSubString startingAt:startIndex ifAbsent:exceptionValue caseSensitive:caseSensitive
@@ -3768,7 +3805,7 @@
 !String class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/String.st,v 1.281 2012/04/01 11:27:41 cg Exp $'
+    ^ '$Id: String.st 10812 2012-06-05 12:18:28Z vranyj1 $'
 !
 
 version_CVS
@@ -3776,5 +3813,5 @@
 !
 
 version_SVN
-    ^ '$Id: String.st 10805 2012-04-13 14:03:30Z vranyj1 $'
+    ^ '$Id: String.st 10812 2012-06-05 12:18:28Z vranyj1 $'
 ! !