mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2024-12-23 10:05:40 +00:00
Merge pull request #712 from lunixbochs/go-free-regions
go: fix uc_free, free uc_mem_regions pointer
This commit is contained in:
commit
6378db99dc
|
@ -2,6 +2,7 @@ package unicorn
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
// #include <unicorn/unicorn.h>
|
// #include <unicorn/unicorn.h>
|
||||||
|
@ -17,7 +18,7 @@ func (u *uc) ContextSave(reuse Context) (Context, error) {
|
||||||
if err := errReturn(C.uc_context_alloc(u.handle, ctx)); err != nil {
|
if err := errReturn(C.uc_context_alloc(u.handle, ctx)); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
runtime.SetFinalizer(ctx, func(p Context) { C.uc_free(*p) })
|
runtime.SetFinalizer(ctx, func(p Context) { C.uc_free(unsafe.Pointer(*p)) })
|
||||||
if err := errReturn(C.uc_context_save(u.handle, *ctx)); err != nil {
|
if err := errReturn(C.uc_context_save(u.handle, *ctx)); err != nil {
|
||||||
}
|
}
|
||||||
return ctx, nil
|
return ctx, nil
|
||||||
|
|
|
@ -178,6 +178,7 @@ func (u *uc) MemRegions() ([]*MemRegion, error) {
|
||||||
Prot: int(v.perms),
|
Prot: int(v.perms),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
C.uc_free(unsafe.Pointer(regions))
|
||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue