Module: LLVM::Support

Defined in:
lib/llvm/support.rb,
lib/llvm/core/value.rb

Defined Under Namespace

Modules: C

Class Method Summary collapse

Class Method Details

.allocate_pointers(size_or_values, &block) ⇒ Object



292
293
294
295
296
297
298
299
300
301
302
# File 'lib/llvm/core/value.rb', line 292

def allocate_pointers(size_or_values, &block)
  if size_or_values.is_a?(Integer)
    raise ArgumentError, 'block not given' unless block_given?
    size = size_or_values
    values = (0...size).map { |i| yield i }
  else
    values = size_or_values
    size = values.size
  end
  FFI::MemoryPointer.new(:pointer, size).write_array_of_pointer(values)
end