improve Go binding safety

This commit is contained in:
Ryan Hileman 2015-08-29 08:32:58 -07:00
parent 15f6da1c3a
commit e2036424c1
1 changed files with 6 additions and 0 deletions

View File

@ -72,10 +72,16 @@ func (u *Uc) RegRead(reg int) (uint64, error) {
}
func (u *Uc) MemWrite(addr uint64, data []byte) error {
if len(data) == 0 {
return nil
}
return errReturn(C.uc_mem_write(u.Handle, C.uint64_t(addr), (*C.uint8_t)(unsafe.Pointer(&data[0])), C.size_t(len(data))))
}
func (u *Uc) MemReadInto(dst []byte, addr uint64) error {
if len(dst) == 0 {
return nil
}
return errReturn(C.uc_mem_read(u.Handle, C.uint64_t(addr), (*C.uint8_t)(unsafe.Pointer(&dst[0])), C.size_t(len(dst))))
}