pool_windows.go 712 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //go:build windows
  2. package yu_deflate
  3. import (
  4. "runtime"
  5. "sync"
  6. )
  7. // const (
  8. // LevelMin = 1
  9. // LevelMaxStdZlib = 9
  10. // LevelMax = 12
  11. // LevelDefault = 6
  12. // )
  13. var m_pool_comp = sync.Pool{
  14. New: func() any {
  15. t := new(uintptr)
  16. runtime.SetFinalizer(t, pool_comp_finalizer)
  17. *t, _, _ = libdeflate_alloc_compressor.Call(12)
  18. return t
  19. },
  20. }
  21. func pool_comp_finalizer(t *uintptr) {
  22. libdeflate_free_compressor.Call(*t)
  23. }
  24. var m_pool_decomp = sync.Pool{
  25. New: func() any {
  26. t := new(uintptr)
  27. runtime.SetFinalizer(t, pool_decomp_finalizer)
  28. *t, _, _ = libdeflate_alloc_decompressor.Call()
  29. return t
  30. },
  31. }
  32. func pool_decomp_finalizer(t *uintptr) {
  33. libdeflate_free_decompressor.Call(*t)
  34. }