File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
src/main/ruby/truffleruby/core Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -326,12 +326,15 @@ def self.with_array_of_ints(ints)
326
326
327
327
def self . with_array_of_strings_pointer ( strings )
328
328
Truffle ::FFI ::MemoryPointer . new ( :pointer , strings . size + 1 ) do |ptr |
329
- pointers = strings . map do |str |
330
- Truffle ::FFI ::MemoryPointer . from_string ( str )
329
+ pointers = Truffle ::FFI ::Pool . stack_alloc ( *strings . map { |s | s . bytesize + 1 } )
330
+ begin
331
+ pointers . zip ( strings ) { |sp , s | sp . put_string ( 0 , s ) }
332
+ pointers << Truffle ::FFI ::Pointer ::NULL
333
+ ptr . write_array_of_pointer pointers
334
+ yield ( ptr )
335
+ ensure
336
+ Truffle ::FFI ::Pool . stack_free ( pointers [ 0 ] )
331
337
end
332
- pointers << Truffle ::FFI ::Pointer ::NULL
333
- ptr . write_array_of_pointer pointers
334
- yield ( ptr )
335
338
end
336
339
end
337
340
You can’t perform that action at this time.
0 commit comments