Subject: Re: [ruby-ffi] wiki update on pointers |
From: Chuck Remes |
Date: 5/11/10 12:34 PM |
To: ruby-ffi@googlegroups.com |
It looks correct to me, except in my experience, MemoryPointer makes it unnecessary to wrap malloc(). For example, instead of,LibC.malloc(baz.first.size * baz.size)I would write,MemoryPointer.new(baz.first.size * baz.size).The block form of MemoryPointer is also useful for automatically freeing the pointer when finished.MemoryPointer.new(baz.first.size * baz.size) do |p|p.write_array_of_int(baz)C.DoSomethingWithArrayOfInt(p)end