skl/arena.go
func (s *Arena) putNode(height int) uint32 {
	// Compute the amount of the tower that will never be used, since the height
	// is less than maxHeight.
	unusedSize := (maxHeight - height) * offsetSize

	// Pad the allocation with enough bytes to ensure pointer alignment.
	l := uint32(MaxNodeSize - unusedSize + nodeAlign)
	n := atomic.AddUint32(&s.n, l)
	y.AssertTruef(int(n) <= len(s.buf),
		"Arena too small, toWrite:%d newTotal:%d limit:%d",
		l, n, len(s.buf))

	// Return the aligned offset.
	m := (n - l + uint32(nodeAlign)) & ^uint32(nodeAlign)
	return m
}
func (s *Arena) putNode(height int) uint32 {
	// Compute the amount of the tower that will never be used, since the height
	// is less than maxHeight.
	unusedSize := (maxHeight - height) * offsetSize

	// Pad the allocation with enough bytes to ensure pointer alignment.
	l := uint32(MaxNodeSize - unusedSize + nodeAlign)
	n := atomic.AddUint32(&s.n, l)
	y.AssertTruef(int(n) <= len(s.buf),
		"Arena too small, toWrite:%d newTotal:%d limit:%d",
		l, n, len(s.buf))

	// Return the aligned offset.
	m := (n - l + uint32(nodeAlign)) & ^uint32(nodeAlign)
	return m
}
func ( s * Arena ) putNode ( height int ) uint32 { // Compute the amount of the tower that will never be used, since the height // is less than maxHeight. unusedSize := ( maxHeight - height ) * offsetSize // Pad the allocation with enough bytes to ensure pointer alignment. l := uint32 ( MaxNodeSize - unusedSize + nodeAlign ) n := atomic . AddUint32 ( & s . n , l ) y . AssertTruef ( int ( n ) <= len ( s . buf ) , " " , l , n , len ( s . buf ) ) // Return the aligned offset. m := ( n - l + uint32 ( nodeAlign ) ) & ^ uint32 ( nodeAlign ) return m }
// putNode allocates a node in the arena. The node is aligned on a pointer-sized
// boundary. The arena offset of the node is returned.
putNode allocates a node in the arena . The node is aligned on a pointer - sized boundary . The arena offset of the node is returned .