Module: Marquise::FFI
- Extended by:
- FFI::Library
- Defined in:
- lib/marquise/ffi.rb
Class Method Summary collapse
-
.pointer_list_from_string_array(ary) ⇒ Object
Common helper to take an array of strings (or things that we’ll turn into strings) and turn it into an FFI::MemoryPointer containing FFI::MemoryPointers for each string.
Class Method Details
.pointer_list_from_string_array(ary) ⇒ Object
Common helper to take an array of strings (or things that we’ll turn into strings) and turn it into an FFI::MemoryPointer containing FFI::MemoryPointers for each string.
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/marquise/ffi.rb', line 54 def self.pointer_list_from_string_array(ary) ptrs = [] ary.each { |e| ptrs << ::FFI::MemoryPointer.from_string(e.to_s) } ptrs << nil ptr = ::FFI::MemoryPointer.new(:pointer, ptrs.length) ptrs.each_with_index { |p, i| ptr[i].write_pointer(p) } ptr end |