Allocate memory for hash values coming from JIT

This commit is contained in:
Paweł Bylica 2015-01-15 16:43:08 +01:00
parent 06e0da25bc
commit 548c9aef82

View file

@ -61,13 +61,15 @@ func hash2llvm(h []byte) i256 {
return m return m
} }
func llvm2hash(m *i256) []byte { //TODO: It should copy data func llvm2hash(m *i256) []byte {
hash := make([]byte, len(m))
hdr := reflect.SliceHeader{ hdr := reflect.SliceHeader{
Data: uintptr(unsafe.Pointer(m)), Data: uintptr(unsafe.Pointer(m)),
Len: int(len(m)), Len: int(len(m)),
Cap: int(len(m)), Cap: int(len(m)),
} }
return *(*[]byte)(unsafe.Pointer(&hdr)) copy(hash, *(*[]byte)(unsafe.Pointer(&hdr)))
return hash
} }
func bswap(m *i256) *i256 { func bswap(m *i256) *i256 {