diff options
Diffstat (limited to 'util.go')
| -rw-r--r-- | util.go | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -7,8 +7,22 @@ import ( ) // #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)) } |
