added System _malloc/_calloc/_free and SmallPointer free
This commit is contained in:
@ -528,18 +528,3 @@ extend Error
|
||||
method(#primitive) asCharacter.
|
||||
method(#primitive) asString.
|
||||
}
|
||||
|
||||
|
||||
class SmallPointer(Object)
|
||||
{
|
||||
method(#primitive) asString.
|
||||
|
||||
method(#primitive) getInt8 (offset).
|
||||
method(#primitive) getInt16 (offset).
|
||||
method(#primitive) getInt32 (offset).
|
||||
method(#primitive) getInt64 (offset).
|
||||
method(#primitive) getUint8 (offset).
|
||||
method(#primitive) getUint16(offset).
|
||||
method(#primitive) getUint32(offset).
|
||||
method(#primitive) getUint64(offset).
|
||||
}
|
||||
|
@ -323,16 +323,20 @@ class MyObject(Object)
|
||||
|
||||
|
||||
(* basicAt: 12 to access the nsdic field. use a proper method once it's defined in Class *)
|
||||
(System nsdic) keysAndValuesDo: [:k :v |
|
||||
k dump.
|
||||
v dump.
|
||||
'------------' dump.
|
||||
].
|
||||
## (System nsdic) keysAndValuesDo: [:k :v |
|
||||
## k dump.
|
||||
## v dump.
|
||||
## '------------' dump.
|
||||
## ].
|
||||
|
||||
|
||||
(System at: #Processor) dump.
|
||||
System logNl: 'Sleeping start now....'.
|
||||
|
||||
a := System _malloc(200).
|
||||
a dump.
|
||||
##System _free(a).
|
||||
a free.
|
||||
Processor sleepFor: 2.
|
||||
}
|
||||
|
||||
|
@ -100,6 +100,11 @@ extend System
|
||||
^self nsdic at: key put: value
|
||||
}
|
||||
|
||||
(* raw memory allocation *)
|
||||
method(#class,#primitive) _malloc (size).
|
||||
method(#class,#primitive) _calloc (size).
|
||||
method(#class,#primitive) _free (rawptr).
|
||||
|
||||
(* raw memory access *)
|
||||
method(#class,#primitive) _getInt8 (rawptr, offset). ## <primitive: #System__getInt8>
|
||||
method(#class,#primitive) _getInt16 (rawptr, offset).
|
||||
@ -121,3 +126,20 @@ extend System
|
||||
method(#class,#primitive) _putUint64 (rawptr, offset, value),
|
||||
*)
|
||||
}
|
||||
|
||||
|
||||
class SmallPointer(Object)
|
||||
{
|
||||
method(#primitive) asString.
|
||||
|
||||
method(#primitive) getInt8 (offset).
|
||||
method(#primitive) getInt16 (offset).
|
||||
method(#primitive) getInt32 (offset).
|
||||
method(#primitive) getInt64 (offset).
|
||||
method(#primitive) getUint8 (offset).
|
||||
method(#primitive) getUint16(offset).
|
||||
method(#primitive) getUint32(offset).
|
||||
method(#primitive) getUint64(offset).
|
||||
|
||||
method(#primitive) free.
|
||||
}
|
||||
|
Reference in New Issue
Block a user