From: Tomasz Wegrzanowski Date: 2001-12-28T17:11:48+09:00 Subject: [ruby-talk:29519] Re: C extensions: ruby and C strings On Fri, Dec 28, 2001 at 04:42:50PM +0900, Yukihiro Matsumoto wrote: > |1) Should I free string here or is it used as string buffer by Ruby ? > | > | char *cstr; > | VALUE rstr; > | > | rstr = rb_str_new2(cstr); > | free (cstr); // ??? > > rb_str_new2() copies c string, so that you have to free cstr. Is there any method for creating Ruby string from C string without allocating and copying ? In case when cstr is big (more than a few kilobytes), it might be major performance gain.