mirror of https://github.com/hak5/bolt.git
Fix freelist.size calculation for large freelists
freelist.size did not account for the extra fake freelist item used to hold the number of elements when the freelist is large.master
parent
0e120dc470
commit
7adfa44e02
|
@ -24,7 +24,12 @@ func newFreelist() *freelist {
|
||||||
|
|
||||||
// size returns the size of the page after serialization.
|
// size returns the size of the page after serialization.
|
||||||
func (f *freelist) size() int {
|
func (f *freelist) size() int {
|
||||||
return pageHeaderSize + (int(unsafe.Sizeof(pgid(0))) * f.count())
|
n := f.count()
|
||||||
|
if n >= 0xFFFF {
|
||||||
|
// The first element will be used to store the count. See freelist.write.
|
||||||
|
n++
|
||||||
|
}
|
||||||
|
return pageHeaderSize + (int(unsafe.Sizeof(pgid(0))) * n)
|
||||||
}
|
}
|
||||||
|
|
||||||
// count returns count of pages on the freelist
|
// count returns count of pages on the freelist
|
||||||
|
|
Loading…
Reference in New Issue