Commit 4562784b authored by Matthew Dempsky's avatar Matthew Dempsky

runtime: remove some unnecessary unsafe code in mfixalloc

Change-Id: Ie9ea4af4315a4d0eb69d0569726bb3eca2b397af
Reviewed-on: https://go-review.googlesource.com/16005Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 368f73bc
......@@ -20,7 +20,7 @@ import "unsafe"
// smashed by freeing and reallocating.
type fixalloc struct {
size uintptr
first unsafe.Pointer // go func(unsafe.pointer, unsafe.pointer); f(arg, p) called first time p is returned
first func(arg, p unsafe.Pointer) // called first time p is returned
arg unsafe.Pointer
list *mlink
chunk *byte
......@@ -40,9 +40,9 @@ type mlink struct {
// Initialize f to allocate objects of the given size,
// using the allocator to obtain chunks of memory.
func fixAlloc_Init(f *fixalloc, size uintptr, first func(unsafe.Pointer, unsafe.Pointer), arg unsafe.Pointer, stat *uint64) {
func fixAlloc_Init(f *fixalloc, size uintptr, first func(arg, p unsafe.Pointer), arg unsafe.Pointer, stat *uint64) {
f.size = size
f.first = *(*unsafe.Pointer)(unsafe.Pointer(&first))
f.first = first
f.arg = arg
f.list = nil
f.chunk = nil
......@@ -70,8 +70,7 @@ func fixAlloc_Alloc(f *fixalloc) unsafe.Pointer {
v := unsafe.Pointer(f.chunk)
if f.first != nil {
fn := *(*func(unsafe.Pointer, unsafe.Pointer))(unsafe.Pointer(&f.first))
fn(f.arg, v)
f.first(f.arg, v)
}
f.chunk = (*byte)(add(unsafe.Pointer(f.chunk), f.size))
f.nchunk -= uint32(f.size)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment