Source File
mfixalloc.go
Belonging Package
runtime
package runtime
import
type fixalloc struct {
size uintptr
first func(arg, p unsafe.Pointer) // called first time p is returned
arg unsafe.Pointer
list *mlink
chunk uintptr // use uintptr instead of unsafe.Pointer to avoid write barriers
nchunk uint32
inuse uintptr // in-use bytes now
stat *sysMemStat
zero bool // zero allocations
}
func ( *fixalloc) ( uintptr, func(, unsafe.Pointer), unsafe.Pointer, *sysMemStat) {
.size =
.first =
.arg =
.list = nil
.chunk = 0
.nchunk = 0
.inuse = 0
.stat =
.zero = true
}
func ( *fixalloc) () unsafe.Pointer {
if .size == 0 {
print("runtime: use of FixAlloc_Alloc before FixAlloc_Init\n")
throw("runtime: internal error")
}
if .list != nil {
:= unsafe.Pointer(.list)
.list = .list.next
.inuse += .size
if .zero {
memclrNoHeapPointers(, .size)
}
return
}
if uintptr(.nchunk) < .size {
.chunk = uintptr(persistentalloc(_FixAllocChunk, 0, .stat))
.nchunk = _FixAllocChunk
}
:= unsafe.Pointer(.chunk)
if .first != nil {
.first(.arg, )
}
.chunk = .chunk + .size
.nchunk -= uint32(.size)
.inuse += .size
return
}
func ( *fixalloc) ( unsafe.Pointer) {
.inuse -= .size
:= (*mlink)()
.next = .list
.list =
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |