From: Justin Bonnar Date: 2006-09-13T17:00:57+09:00 Subject: Re: Wrapping a C Library: Allocation and duplication issues Acutally, I'm not a C or Ruby/C guru, but would any of the following be possible? - Wrapping a null pointer in the allocation function, and then modifying the DATA object to use the pointer returned by the librdf_new_classname() call. - Creating a pointer to the data structure, and then setting it's value to the pointer returned by the librdf_new_classname() call. The following code compiles and runs, but doesn't seem to work correctly (other functions that access the C structure wrapped by the object behave strangely.) static VALUE URI_alloc(VALUE klass) { librdf_uri* uri; return Data_Wrap_Struct(klass, 0, librdf_free_uri, uri); } static VALUE URI_initialize(VALUE self, VALUE uri_string) { librdf_uri* uri; Data_Get_Struct(self, librdf_uri, uri); uri = librdf_new_uri(World, StringValuePtr(uri_string)); return self; } Thanks, Justin -- Posted via http://www.ruby-forum.com/.