summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.go5
-rw-r--r--util.go25
2 files changed, 26 insertions, 4 deletions
diff --git a/main.go b/main.go
index ce66591..a5b4269 100644
--- a/main.go
+++ b/main.go
@@ -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())
}
diff --git a/util.go b/util.go
new file mode 100644
index 0000000..cfcb677
--- /dev/null
+++ b/util.go
@@ -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
+}