Module: HeapInfo::Glibc

Included in:
Libc
Defined in:
lib/heapinfo/glibc/free.rb,
lib/heapinfo/glibc/error.rb,
lib/heapinfo/glibc/glibc.rb,
lib/heapinfo/glibc/helper.rb

Overview

Define some useful functions here.

Defined Under Namespace

Classes: Error, MallocError

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#size_tObject

Returns the value of attribute size_t


4
5
6
# File 'lib/heapinfo/glibc/glibc.rb', line 4

def size_t
  @size_t
end

Instance Method Details

#libc_free(mem) ⇒ Object Also known as: free

Implmentation of void __libc_free(void *mem).

Reference: glibc-2.23 and Online Source

Parameters:

  • mem (Integer)

    Memory address to be free.


10
11
12
13
14
15
16
17
18
# File 'lib/heapinfo/glibc/free.rb', line 10

def libc_free(mem)
  # TODO: free_hook
  mem = ulong mem
  return if mem.zero? # free(0) has no effect
  ptr = mem2chunk(mem)
  return munmap_chunk(ptr) if chunk_is_mmapped(ptr)
  av = arena_for_chunk(ptr)
  int_free(av, ptr)
end

#malloc_assert(condition) ⇒ Object

Raises:


8
9
10
# File 'lib/heapinfo/glibc/error.rb', line 8

def malloc_assert(condition)
  raise MallocError, yield unless condition
end