Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Ruby
Memory Allocation in Ruby
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="James Tucker, post: 4597639"] def FunctionName(numBytes) bufferSize =3D numBytes * 2 buffer =3D "\0" * bufferSize end Most of the external interfaces can use strings as sets of binary =20 data, as this is our best binary representation at present. If you use a ruby string, instead of a dl.malloc, the only thing you =20 need to ensure is that the data is not GC'd prematurely. This will =20 happen if there are no references left on the ruby side. I can't comment on the semantics of dl, as I've never used it. first_half =3D buffer[0..half] sec_half =3D buffer[half..-1] You won't need to memcpy if you're treating the data as a regular ruby =20= string. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Ruby
Memory Allocation in Ruby
Top