From 766f9ed028c757561b99e4ed5aa487d381fe80a3 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 26 Aug 2018 10:19:10 -0400 Subject: Migrated util.go and main.go to the new pkgui convention and C file. Also replaced C.CBytes() with C.malloc() (this bumps our minimum version requirement to 1.8, but it's better than keeping a massive slice around at all times). --- util.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 util.go (limited to 'util.go') diff --git a/util.go b/util.go new file mode 100644 index 0000000..667f679 --- /dev/null +++ b/util.go @@ -0,0 +1,31 @@ +// 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 + 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 +} -- cgit v1.2.3