Skip to content

Commit

Permalink
Fix Pointer#write_array_of_type
Browse files Browse the repository at this point in the history
  • Loading branch information
ytaka committed Oct 20, 2018
1 parent aa1b844 commit 65b53d2
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/ffi/pointer.rb
Expand Up @@ -124,10 +124,9 @@ def read_array_of_type(type, reader, length)
# ptr.write_array_of_type(TYPE_UINT8, :put_uint8, [1, 2, 3 ,4])
def write_array_of_type(type, writer, ary)
size = FFI.type_size(type)
tmp = self
ary.each_with_index {|i, j|
tmp.send(writer, i)
tmp += size unless j == ary.length-1 # avoid OOB
ary.each_with_index { |val, i|
break unless i < self.size
self.send(writer, i * size, val)
}
self
end
Expand Down

0 comments on commit 65b53d2

Please sign in to comment.