()
| 130 | } |
| 131 | |
| 132 | func (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 | |
| 152 | func (p *Page) FreelistPageIds() []Pgid { |
| 153 | if !p.IsFreelistPage() { |
no test coverage detected