Sha256: 8448d17ed2e11277d596fc86bac59026c5ba51cb38f559a099087d83f894ec85

Contents?: true

Size: 335 Bytes

Versions: 3

Compression:

Stored size: 335 Bytes

Contents

# frozen_string_literal: true
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

3 entries across 3 versions & 1 rubygems

Version Path
gir_ffi-0.9.5 lib/gir_ffi/allocation_helper.rb
gir_ffi-0.9.4 lib/gir_ffi/allocation_helper.rb
gir_ffi-0.9.3 lib/gir_ffi/allocation_helper.rb