code: func (db *DB) allocate(count int) (*page, error) {
  	// Allocate a temporary buffer for the page.
  	var buf []byte
  	if count == 1 {
  		buf = db.pagePool.Get().([]byte)
  	} else {
  		buf = make([]byte, count*db.pageSize)
  	}
  	p := (*page)(unsafe.Pointer(&buf[0]))
  	p.overflow = uint32(count - 1)
  
  	// Use pages from the freelist if they are available.
  	if p.id = db.freelist.allocate(count); p.id != 0 {
  		return p, nil
  	}
  
  	// Resize mmap() if we're at the end.
  	p.id = db.rwtx.meta.pgid
  	var minsz = int((p.id+pgid(count))+1) * db.pageSize
  	if minsz >= db.datasz {
  		if err := db.mmap(minsz); err != nil {
  			return nil, fmt.Errorf("mmap allocate error: %s", err)
  		}
  	}
  
  	// Move the page id high water mark.
  	db.rwtx.meta.pgid += pgid(count)
  
  	return p, nil
  }
docs: // allocate returns a contiguous block of memory starting at a given page.