class HeapInfo::UnsortedBin

Class for record unsorted bin type chunk.

Attributes

bk[R]

@return [Integer]

Public Class Methods

new(*args) click to toggle source

Instantiate a {HeapInfo::UnsortedBin} object.

@param [Mixed] args See {HeapInfo::Chunk} for more information.

Calls superclass method HeapInfo::Fastbin::new
# File lib/heapinfo/arena.rb, line 166
def initialize(*args)
  super
  @bk = Helper.unpack(size_t, @data[@size_t, @size_t])
end

Public Instance Methods

inspect(size: 2) click to toggle source

@param [Integer] size

At most expand size. For +size = 2+, the expand list would be <tt>bk, bk, bin, fd, fd</tt>.

@return [String] Unsorted bin layouts wrapper with color codes.

# File lib/heapinfo/arena.rb, line 174
def inspect(size: 2)
  list = link_list(size)
  return '' if list.size <= 1 && Helper.class_name(self) != 'UnsortedBin' # bad..
  title + pretty_list(list) + "\n"
end
pretty_list(list) click to toggle source

Wrapper the doubly linked list with color codes. @param [Array<Integer>] list The list from {#link_list}. @return [String] Wrapper with color codes.

# File lib/heapinfo/arena.rb, line 183
def pretty_list(list)
  center = nil
  list.map.with_index do |c, idx|
    next center = Helper.color('[self]', sev: :bin) if c == @base
    color_c = Helper.color(format('%#x', c))
    fwd = fd_of(c)
    next "#{color_c}(invalid)" if fwd.nil? # invalid c
    bck = bk_of(c)
    if center.nil? # bk side
      format('%s%s', color_c, fwd == list[idx + 1] ? nil : Helper.color(format('(%#x)', fwd)))
    else # fd side
      format('%s%s', bck == list[idx - 1] ? nil : Helper.color(format('(%#x)', bck)), color_c)
    end
  end.join(' === ')
end