Created
June 29, 2012 15:11
-
-
Save djberg96/3018498 to your computer and use it in GitHub Desktop.
Problem initializing array of union
This file contains hidden or 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
# It seems this is the wrong way to create an array of union in FFI. What's the right way? | |
array = [] | |
# FileSegmentElement is an FFI::Union, and :Alignment is a :uint64 | |
for i in 0...page_num | |
segment = FileSegmentElement.new | |
segment[:Alignment] = base_address + page_size * i | |
array << segment | |
end | |
# Add an extra element for null | |
array << FileSegmentElement.new | |
segment_array = FFI::MemoryPointer.new(FileSegmentElement, array.length) | |
segment_array.put_array_of_pointer(0, array) | |
# Seems to work but a call to ReadFileScatter simply returns "the parameter is incorrect". |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment