summaryrefslogtreecommitdiff
path: root/BBB_GOFILES/util.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2018-08-26 10:19:10 -0400
committerPietro Gagliardi <[email protected]>2018-08-26 10:19:10 -0400
commit766f9ed028c757561b99e4ed5aa487d381fe80a3 (patch)
treebdbeb748f2a88a47f6b246ffa1a72cd6c0da4689 /BBB_GOFILES/util.go
parent62ac2527732a01dfa6bd2c9523215c0ba3816641 (diff)
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).
Diffstat (limited to 'BBB_GOFILES/util.go')
-rw-r--r--BBB_GOFILES/util.go45
1 files changed, 0 insertions, 45 deletions
diff --git a/BBB_GOFILES/util.go b/BBB_GOFILES/util.go
deleted file mode 100644
index bcd4d33..0000000
--- a/BBB_GOFILES/util.go
+++ /dev/null
@@ -1,45 +0,0 @@
-// 12 december 2015
-
-package ui
-
-import (
- "unsafe"
-)
-
-// #include <stdlib.h>
-// #include "util.h"
-import "C"
-
-// We want Go itself to complain when we're out of memory.
-// The allocators in cgo *should* do this, but there isn't a
-// C.CMalloc(). There *is* a C.CBytes(), however, for transferring
-// binary blobs from Go to C. If we pass this an arbitrary slice
-// of the desired length, we get our C.CMalloc(). Using a slice
-// that's always initialized to zero gives us the memset(0)
-// (or ZeroMemory()) for free.
-var allocBytes = make([]byte, 1024) // 1024 bytes first
-
-//export pkguiAlloc
-func pkguiAlloc(n C.size_t) unsafe.Pointer {
- if n > C.size_t(len(allocBytes)) {
- // TODO round n up to a multiple of a power of 2?
- // for instance 0x1234 bytes -> 0x1800 bytes
- allocBytes = make([]byte, n)
- }
- return C.CBytes(allocBytes[: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
-}