Sha256: ec0b9d395f9bd2a7bfb5c2f85a4edb630473b1e47cf541e5fc3bc304ee703fa9

Contents?: true

Size: 305 Bytes

Versions: 10

Compression:

Stored size: 305 Bytes

Contents

require 'gir_ffi/lib_c'

module GirFFI
  # Helper module providing a safe allocation method that raises an exception
  # if memory cannot be allocated.
  module AllocationHelper
    def self.safe_malloc(size)
      ptr = LibC.malloc size
      raise NoMemoryError if ptr.null?
      ptr
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
gir_ffi-0.9.2 lib/gir_ffi/allocation_helper.rb
gir_ffi-0.9.1 lib/gir_ffi/allocation_helper.rb
gir_ffi-0.9.0 lib/gir_ffi/allocation_helper.rb
gir_ffi-0.8.6 lib/gir_ffi/allocation_helper.rb
gir_ffi-0.8.5 lib/gir_ffi/allocation_helper.rb
gir_ffi-0.8.4 lib/gir_ffi/allocation_helper.rb
gir_ffi-0.8.3 lib/gir_ffi/allocation_helper.rb
gir_ffi-0.8.2 lib/gir_ffi/allocation_helper.rb
gir_ffi-0.8.1 lib/gir_ffi/allocation_helper.rb
gir_ffi-0.8.0 lib/gir_ffi/allocation_helper.rb