We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7d225eb commit 7e4cf34Copy full SHA for 7e4cf34
lib/thundersvm/model.rb
@@ -159,9 +159,11 @@ def create_dataset(x, y = nil)
159
160
def str_ptr(arr)
161
ptr = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP * arr.size, Fiddle::RUBY_FREE)
162
- arr.each_with_index do |v, i|
163
- ptr[i * Fiddle::SIZEOF_VOIDP, Fiddle::SIZEOF_VOIDP] = Fiddle::Pointer["#{v}\x00"].ref
+ str_ptrs = arr.map { |v| Fiddle::Pointer["#{v}\x00"] }
+ str_ptrs.each_with_index do |v, i|
164
+ ptr[i * Fiddle::SIZEOF_VOIDP, Fiddle::SIZEOF_VOIDP] = v.ref
165
end
166
+ ptr.instance_variable_set(:@thundersvm_refs, str_ptrs)
167
ptr
168
169
0 commit comments