Implemented some utility functions.

This commit is contained in:
Pietro Gagliardi 2015-12-12 13:07:57 -05:00
parent b6ccf2db40
commit a181d36b58
2 changed files with 26 additions and 4 deletions

View File

@ -121,8 +121,5 @@ func doOnShouldQuit(unused unsafe.Pointer) C.int {
if shouldQuitFunc == nil {
return 0
}
if shouldQuitFunc() {
return 1
}
return 0
return frombool(shouldQuitFunc())
}

25
util.go Normal file
View File

@ -0,0 +1,25 @@
// 12 december 2015
package ui
import (
"unsafe"
)
// #include <stdlib.h>
import "C"
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
}