-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutil.go
More file actions
44 lines (37 loc) · 717 Bytes
/
util.go
File metadata and controls
44 lines (37 loc) · 717 Bytes
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
40
41
42
43
44
package vk
// #include <stdlib.h>
// #include "vk.h"
import "C"
import (
"bytes"
"unsafe"
)
func externString(a *allocator, s string) *C.char {
m := C.CString(s)
a.allocs = append(a.allocs, unsafe.Pointer(m))
return m
}
func externStrings(a *allocator, ss []string) **C.char {
cstrings := make([]*C.char, len(ss))
for i, s := range ss {
cstrings[i] = externString(a, s)
}
return pinSlice(a, cstrings)
}
func result2error(res Result) error {
if res == Success {
return nil
}
return res
}
func vkBool(b bool) C.VkBool32 {
if b {
return C.VK_TRUE
}
return C.VK_FALSE
}
func str(x []C.char) string {
v := *(*[]byte)(unsafe.Pointer(&x))
idx := bytes.IndexByte(v, 0)
return string(v[:idx])
}