mirror of
https://github.com/golang/go
synced 2024-11-24 01:20:08 -07:00
runtime: change fixalloc's chunk field to unsafe.Pointer
It's never used as a *byte anyway, so might as well just make it an unsafe.Pointer instead. Change-Id: I68ee418781ab2fc574eeac0498f2515b5561b7a8 Reviewed-on: https://go-review.googlesource.com/16175 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
1948aef6e3
commit
29330c118d
@ -23,7 +23,7 @@ type fixalloc struct {
|
|||||||
first func(arg, p unsafe.Pointer) // called first time p is returned
|
first func(arg, p unsafe.Pointer) // called first time p is returned
|
||||||
arg unsafe.Pointer
|
arg unsafe.Pointer
|
||||||
list *mlink
|
list *mlink
|
||||||
chunk *byte
|
chunk unsafe.Pointer
|
||||||
nchunk uint32
|
nchunk uint32
|
||||||
inuse uintptr // in-use bytes now
|
inuse uintptr // in-use bytes now
|
||||||
stat *uint64
|
stat *uint64
|
||||||
@ -64,15 +64,15 @@ func fixAlloc_Alloc(f *fixalloc) unsafe.Pointer {
|
|||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
if uintptr(f.nchunk) < f.size {
|
if uintptr(f.nchunk) < f.size {
|
||||||
f.chunk = (*uint8)(persistentalloc(_FixAllocChunk, 0, f.stat))
|
f.chunk = persistentalloc(_FixAllocChunk, 0, f.stat)
|
||||||
f.nchunk = _FixAllocChunk
|
f.nchunk = _FixAllocChunk
|
||||||
}
|
}
|
||||||
|
|
||||||
v := unsafe.Pointer(f.chunk)
|
v := f.chunk
|
||||||
if f.first != nil {
|
if f.first != nil {
|
||||||
f.first(f.arg, v)
|
f.first(f.arg, v)
|
||||||
}
|
}
|
||||||
f.chunk = (*byte)(add(unsafe.Pointer(f.chunk), f.size))
|
f.chunk = add(f.chunk, f.size)
|
||||||
f.nchunk -= uint32(f.size)
|
f.nchunk -= uint32(f.size)
|
||||||
f.inuse += f.size
|
f.inuse += f.size
|
||||||
return v
|
return v
|
||||||
|
Loading…
Reference in New Issue
Block a user