TypeError Message. Help required

I have created an extension and within the extension file I have
declared one function like-

VALUE free(T * self, VALUE name) //T is the struct
{
free(StringValuePtr(name));
}

rb_define_method(hw_cMyClass, “free”, talloc_free,0);

And from *.rb file I am calling the free function like

t.free()

But its giving me error like-

rungc.rb:10:in `free’: can’t convert false into String (TypeError)
from rungc.rb:10

Can anyone tell me what I am doing wrong? ANd how to fix it?

Regards

Tridib

On Mon, Apr 2, 2012 at 2:18 PM, Tridib B.
[email protected] wrote:

And from *.rb file I am calling the free function like

t.free()

But its giving me error like-

rungc.rb:10:in `free’: can’t convert false into String (TypeError)
from rungc.rb:10

Can anyone tell me what I am doing wrong? ANd how to fix it?

I don’t know precisely, but I can tell you that your call to
rb_define_method sets it up so the C function talloc_free is the
implementation of the Ruby free method – not the function you have
defined as free. Also note that it’s a bad idea (if it’s allowed at
all) to name something free in C – that’s the name of the standard
library’s free function.