Module: GirFFI::AllocationHelper

Defined in:
lib/gir_ffi/allocation_helper.rb

Overview

Helper module providing a safe allocation method that raises an exception if memory cannot be allocated.

Class Method Summary collapse

Class Method Details

.safe_malloc(size) ⇒ Object

Raises:

  • (NoMemoryError)


7
8
9
10
11
# File 'lib/gir_ffi/allocation_helper.rb', line 7

def self.safe_malloc(size)
  ptr = LibC.malloc size
  raise NoMemoryError if ptr.null?
  ptr
end