diff options
author | Vadim Markovtsev <vadim@sourced.tech> | 2016-06-21 17:14:53 +0300 |
---|---|---|
committer | Vadim Markovtsev <vadim@sourced.tech> | 2016-06-21 17:14:53 +0300 |
commit | da07dca4523ebd25c634152a62cae4a72eb5783f (patch) | |
tree | 028122b562ce464ae4410525b5b3d3dfcea4846c /cshared/objects.go | |
parent | bea415417e87fbb403095e8cd3fb8512a1a97af8 (diff) | |
download | go-git-da07dca4523ebd25c634152a62cae4a72eb5783f.tar.gz |
Wrap more objects with CGo
Diffstat (limited to 'cshared/objects.go')
-rw-r--r-- | cshared/objects.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/cshared/objects.go b/cshared/objects.go index 0517449..ae3440d 100644 --- a/cshared/objects.go +++ b/cshared/objects.go @@ -140,6 +140,13 @@ func CopyString(str string) string { return string(buf) } +// https://github.com/golang/go/issues/14838 +func CBytes(bytes []byte) *C.char { + ptr := C.malloc(C.size_t(len(bytes))) + copy((*[1<<30]byte)(ptr)[:], bytes) + return (*C.char)(ptr) +} + func SafeIsNil(v reflect.Value) bool { defer func() { recover() }() return v.IsNil() |