Sha256: f9cbc51f3cbbd0095a7018a3a33fa9f35a040774b8bbaf7c43c128f75ccf85ef

Contents?: true

Size: 304 Bytes

Versions: 6

Compression:

Stored size: 304 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

6 entries across 6 versions & 1 rubygems

Version Path
gir_ffi-0.7.10 lib/gir_ffi/allocation_helper.rb
gir_ffi-0.7.9 lib/gir_ffi/allocation_helper.rb
gir_ffi-0.7.8 lib/gir_ffi/allocation_helper.rb
gir_ffi-0.7.7 lib/gir_ffi/allocation_helper.rb
gir_ffi-0.7.6 lib/gir_ffi/allocation_helper.rb
gir_ffi-0.7.5 lib/gir_ffi/allocation_helper.rb