2018-08-26 09:19:10 -05:00
|
|
|
// 12 december 2015
|
|
|
|
|
|
|
|
package ui
|
|
|
|
|
|
|
|
import (
|
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
|
|
|
// #include "pkgui.h"
|
|
|
|
import "C"
|
|
|
|
|
|
|
|
//export pkguiAlloc
|
|
|
|
func pkguiAlloc(n C.size_t) unsafe.Pointer {
|
|
|
|
// cgo turns C.malloc() into a panic-on-OOM version; use it
|
2018-08-26 12:18:53 -05:00
|
|
|
// TODO make sure it zero-initializes too
|
2018-08-26 09:19:10 -05:00
|
|
|
return C.malloc(n)
|
|
|
|
}
|
|
|
|
|
|
|
|
func freestr(str *C.char) {
|
|
|
|
C.free(unsafe.Pointer(str))
|
|
|
|
}
|
|
|
|
|
|
|
|
func tobool(b C.int) bool {
|
|
|
|
return b != 0
|
|
|
|
}
|
|
|
|
|
|
|
|
func frombool(b bool) C.int {
|
|
|
|
if b {
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
return 0
|
|
|
|
}
|