Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. import scala.scalanative.libc.stdlib._
  2. import scala.scalanative.unsafe._
  3.  
  4. object leak {
  5. import Uv._
  6. import UvConstants._
  7.  
  8. val loop = uv_default_loop()
  9.  
  10. val cbTimer: CFuncPtr1[TimerHandle, Unit] = new CFuncPtr1[TimerHandle, Unit] {
  11. def apply(handle: TimerHandle): Unit = {}
  12. }
  13.  
  14. val timer = malloc(uv_handle_size(UV_TIMER_T))
  15.  
  16. def main(args: Array[String]): Unit = {
  17. uv_timer_init(loop, timer)
  18. uv_timer_start(timer, cbTimer, 0, 1)
  19.  
  20. uv_run(loop, UV_RUN_DEFAULT)
  21. }
  22. }
  23.  
  24. @link("uv")
  25. @extern
  26. object Uv {
  27. type Loop = Ptr[Byte]
  28.  
  29. type TimerHandle = Ptr[Byte]
  30. type TimerCB = CFuncPtr1[TimerHandle, Unit]
  31.  
  32. def uv_timer_init(loop: Loop, handle: TimerHandle): Int = extern
  33. def uv_timer_start(handle: TimerHandle, cb: TimerCB, timeout: Long, repeat: Long): Int = extern
  34.  
  35. def uv_default_loop(): Loop = extern
  36. def uv_run(loop: Loop, runMode: Int): Int = extern
  37. def uv_handle_size(h_type: Int): CSize = extern
  38. }
  39.  
  40. object UvConstants {
  41. val UV_RUN_DEFAULT = 0
  42. val UV_TIMER_T = 13
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement