Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import scala.scalanative.libc.stdlib._
- import scala.scalanative.unsafe._
- object leak {
- import Uv._
- import UvConstants._
- val loop = uv_default_loop()
- val cbTimer: CFuncPtr1[TimerHandle, Unit] = new CFuncPtr1[TimerHandle, Unit] {
- def apply(handle: TimerHandle): Unit = {}
- }
- val timer = malloc(uv_handle_size(UV_TIMER_T))
- def main(args: Array[String]): Unit = {
- uv_timer_init(loop, timer)
- uv_timer_start(timer, cbTimer, 0, 1)
- uv_run(loop, UV_RUN_DEFAULT)
- }
- }
- @link("uv")
- @extern
- object Uv {
- type Loop = Ptr[Byte]
- type TimerHandle = Ptr[Byte]
- type TimerCB = CFuncPtr1[TimerHandle, Unit]
- def uv_timer_init(loop: Loop, handle: TimerHandle): Int = extern
- def uv_timer_start(handle: TimerHandle, cb: TimerCB, timeout: Long, repeat: Long): Int = extern
- def uv_default_loop(): Loop = extern
- def uv_run(loop: Loop, runMode: Int): Int = extern
- def uv_handle_size(h_type: Int): CSize = extern
- }
- object UvConstants {
- val UV_RUN_DEFAULT = 0
- val UV_TIMER_T = 13
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement