September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View 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
}

View file

@ -0,0 +1 @@
atom mem = allocate(size,true)

View 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

View 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.