Class: FFI::MemoryPointer

Inherits:
Object
  • Object
show all
Defined in:
lib/mpvlib/ffi_additions.rb

Class Method Summary collapse

Class Method Details

.from_array_of_strings(strings) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/mpvlib/ffi_additions.rb', line 22

def self.from_array_of_strings(strings)
  string_ptrs = strings.map { |s| FFI::MemoryPointer.from_string(s) } + [nil]
  strings_ptr = new(:pointer, string_ptrs.length)
  string_ptrs.each_with_index do |ptr, i|
    strings_ptr[i].put_pointer(0, ptr)
  end
  strings_ptr
end