September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
14
Task/Arena-storage-pool/Kotlin/arena-storage-pool.kotlin
Normal file
14
Task/Arena-storage-pool/Kotlin/arena-storage-pool.kotlin
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// Kotlin Native v0.3
|
||||
|
||||
import kotlinx.cinterop.*
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
memScoped {
|
||||
val intVar1 = alloc<IntVar>()
|
||||
intVar1.value = 1
|
||||
val intVar2 = alloc<IntVar>()
|
||||
intVar2.value = 2
|
||||
println("${intVar1.value} + ${intVar2.value} = ${intVar1.value + intVar2.value}")
|
||||
}
|
||||
// native memory used by intVar1 & intVar2 is automatically freed when memScoped block ends
|
||||
}
|
||||
1
Task/Arena-storage-pool/Phix/arena-storage-pool-1.phix
Normal file
1
Task/Arena-storage-pool/Phix/arena-storage-pool-1.phix
Normal file
|
|
@ -0,0 +1 @@
|
|||
atom mem = allocate(size,true)
|
||||
12
Task/Arena-storage-pool/Phix/arena-storage-pool-2.phix
Normal file
12
Task/Arena-storage-pool/Phix/arena-storage-pool-2.phix
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
sequence ap = {}
|
||||
function ap_allocate(integer size)
|
||||
-- allocate some memory and add it to the arena pool 'ap' for later release
|
||||
atom res = allocate(size)
|
||||
ap = append(ap,res)
|
||||
return res
|
||||
end function
|
||||
procedure ap_free()
|
||||
-- free all memory allocated in arena pool 'ap'
|
||||
free(ap)
|
||||
ap = {}
|
||||
end procedure
|
||||
3
Task/Arena-storage-pool/Zkl/arena-storage-pool.zkl
Normal file
3
Task/Arena-storage-pool/Zkl/arena-storage-pool.zkl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
var pool=List(); // pool could be any mutable container
|
||||
pool.append(Data(0,1234)); // allocate mem blob and add to pool
|
||||
pool=Void; // free the pool and everything in it.
|
||||
Loading…
Add table
Add a link
Reference in a new issue