Skip to content

Instantly share code, notes, and snippets.

@djberg96
Created December 17, 2011 14:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djberg96/1490385 to your computer and use it in GitHub Desktop.
Save djberg96/1490385 to your computer and use it in GitHub Desktop.
custom read_array_of_string method dies
class FFI::Pointer
# This works fine on MRI, but dies on JRuby
def read_array_of_string
elements = []
psz = RUBY_PLATFORM == 'java' ? 4 : self.class.size
loc = self
until ((element = loc.read_pointer).null?)
elements << element.read_string
loc += psz
end
elements
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment