From: "Carlo E. Prelz" Date: 2013-04-09T14:46:40+09:00 Subject: Re: Mapping string data ptr to buffer in ffi Subject: Re: Mapping string data ptr to buffer in ffi Date: mar 09 apr 13 05:27:43 +0900 Quoting Jeremy Bopp (jeremy@bopp.net): > Sadly, this doesn't appear to be made available via any functionality of > FFI, so the OP would need to write at least a small amount of his own > glue as a C extension or similarly extend FFI. From the earlier > discussion, the hope is that such functionality already exists in FFI. I know nothing about FFI. Can't help there. > The next question to answer is whether or not the GC will relocate that > buffer behind the back of the C functions. If that might happen, the GC > might need to be disabled during any operations that use the buffer with > the C function. As far as I know, the GC won't operate while your Ruby-called C function is being executed. > In my case at least, all operations on the buffer would only change > content within the existing buffer. The size of the string that owns > the buffer would be unaffected. I think the OP has similar needs from > the sound of it. The OP had quite different needs, if I got this correctly. He wanted huge amounts of strings to be accessible read-only from some form of global memory, and he hoped he could introduce them into the Ruby environment without paying the price of creating String objects (and thus without needing to duplicate the memory needs, and without incurring the performance hit of allocation/deallocation). Carlo -- * Se la Strada e la sua Virtu' non fossero state messe da parte, * K * Carlo E. Prelz - fluido@fluido.as che bisogno ci sarebbe * di parlare tanto di amore e di rettitudine? (Chuang-Tzu)