blob: 2f181c40b1efa5aaec0540fe1e1136696fef5ac8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
// 12 december 2015
package ui
import (
"unsafe"
)
// #include <stdlib.h>
// // TODO remove when switching to Go 1.7
// #include <string.h>
import "C"
// TODO move this to C.CBytes() when switching to Go 1.7
//export uimalloc
func uimalloc(n C.size_t) unsafe.Pointer {
p := C.malloc(n)
if p == nil {
panic("out of memory in uimalloc()")
}
C.memset(p, 0, n)
return p
}
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
}
|