fix/pass_memory_correctly (#1)

Co-authored-by: Kobi Gurkan <kobigurk@gmail.com>
This commit is contained in:
Dean Eigenmann 2021-09-13 22:02:25 +02:00 committed by GitHub
parent 7e89c6ca80
commit 970c92157e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions

View File

@ -14,11 +14,16 @@ type RLN struct {
}
func (r *RLN) Hash(input []byte) []byte {
out := &C.Buffer{}
size := int(unsafe.Sizeof(C.Buffer{}))
out_ptr := C.malloc(C.size_t(size))
in := toBuffer(input)
size = int(unsafe.Sizeof(C.Buffer{}))
in_ptr := C.malloc(C.size_t(size))
in := (*C.Buffer)(in_ptr)
*in = toBuffer(input)
C.hash(r.ptr, &in, &in.len, out)
out := (*C.Buffer)(out_ptr)
C.hash(r.ptr, in, &in.len, out)
return C.GoBytes(unsafe.Pointer(out.ptr), C.int(out.len))
}