Created
December 17, 2011 14:44
-
-
Save djberg96/1490385 to your computer and use it in GitHub Desktop.
custom read_array_of_string method dies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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