MCPcopy
hub / github.com/etcd-io/bbolt / FreelistPageCount

Method FreelistPageCount

internal/common/page.go:132–150  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

130}
131
132func (p *Page) FreelistPageCount() (int, int) {
133 if !p.IsFreelistPage() {
134 panic(fmt.Sprintf("assertion failed: can't get freelist page count from a non-freelist page: %2x", p.flags))
135 }
136
137 // If the page.count is at the max uint16 value (64k) then it's considered
138 // an overflow and the size of the freelist is stored as the first element.
139 var idx, count = 0, int(p.count)
140 if count == 0xFFFF {
141 idx = 1
142 c := *(*Pgid)(UnsafeAdd(unsafe.Pointer(p), unsafe.Sizeof(*p)))
143 count = int(c)
144 if count < 0 {
145 panic(fmt.Sprintf("leading element count %d overflows int", c))
146 }
147 }
148
149 return idx, count
150}
151
152func (p *Page) FreelistPageIds() []Pgid {
153 if !p.IsFreelistPage() {

Callers 2

FreelistPageIdsMethod · 0.95
pagePrintFreelistFunction · 0.80

Calls 2

IsFreelistPageMethod · 0.95
UnsafeAddFunction · 0.85

Tested by

no test coverage detected