]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: remove some unnecessary unsafe code in mfixalloc
authorMatthew Dempsky <mdempsky@google.com>
Fri, 16 Oct 2015 23:21:26 +0000 (16:21 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Sat, 17 Oct 2015 00:26:26 +0000 (00:26 +0000)
Change-Id: Ie9ea4af4315a4d0eb69d0569726bb3eca2b397af
Reviewed-on: https://go-review.googlesource.com/16005
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/runtime/mfixalloc.go

index ec926323d8cdda76765c5ab7f9a0e119061fecfc..57a136d06bfac08c22c75dd9ac726d0b09bfce61 100644 (file)
@@ -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)