DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Getting An Array Of Strings From A Char** With FFI And Ruby
This code adds a method to the FFI::Pointer class that makes it easy to unravel an array of null terminated strings from a char** type.
require 'ffi'
class FFI::Pointer
def read_array_of_string
elements = []
loc = self
until ((element = loc.read_pointer).null?)
elements << element.read_string
loc += FFI::Type::POINTER.size
end
elements
end
end





