Subject:
[ruby-ffi] Is there any way we can use string type as return parameter?
From:
Jesús García Sáez <blaxter@gmail.com>
Date:
3/29/10 12:23 PM
To:
ruby-ffi@googlegroups.com

Hi,

when is it posible to define a "string" type safely? I think, the only situation is for const char * input parameter. Because otherwise we are gonna have memory leaks.

For example, for a function like:

char *foo();

if we attach it with:

attach_function :foo, :foo, [], :string

We are gonna have a nice memory leak because nobody is gonna release that string. When we call "foo" method in ruby, we get a String object, we cannot (or I don't know how) get the actual char pointer to release it (either from ruby or with another attached function where we pass the pointer and that function calls free, delete o whatever is necessary).

To unsubscribe from this group, send email to ruby-ffi+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.