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

Method Write

internal/freelist/shared.go:287–310  ·  view source on GitHub ↗
(p *common.Page)

Source from the content-addressed store, hash-verified

285}
286
287func (t *shared) Write(p *common.Page) {
288 // Combine the old free pgids and pgids waiting on an open transaction.
289
290 // Update the header flag.
291 p.SetFlags(common.FreelistPageFlag)
292
293 // The page.count can only hold up to 64k elements so if we overflow that
294 // number then we handle it by putting the size in the first element.
295 l := t.Count()
296 if l == 0 {
297 p.SetCount(uint16(l))
298 } else if l < 0xFFFF {
299 p.SetCount(uint16(l))
300 data := common.UnsafeAdd(unsafe.Pointer(p), unsafe.Sizeof(*p))
301 ids := unsafe.Slice((*common.Pgid)(data), l)
302 t.Copyall(ids)
303 } else {
304 p.SetCount(0xFFFF)
305 data := common.UnsafeAdd(unsafe.Pointer(p), unsafe.Sizeof(*p))
306 ids := unsafe.Slice((*common.Pgid)(data), l+1)
307 ids[0] = common.Pgid(l)
308 t.Copyall(ids[1:])
309 }
310}

Callers

nothing calls this directly

Calls 6

CountMethod · 0.95
CopyallMethod · 0.95
UnsafeAddFunction · 0.92
PgidTypeAlias · 0.92
SetCountMethod · 0.80
SetFlagsMethod · 0.45

Tested by

no test coverage detected