From: Nikolai Weibull Date: 2010-07-09T22:24:10+09:00 Subject: [ruby-core:31156] Re: Why is there no standard way of creating a String from a char *? On Fri, Jul 9, 2010 at 15:12, Urabe Shyouhei wrote: > No, sorry Ruby can't trust you. ��Not even myself. ��When a machine can trust a > human, there is absolutely zero reason for a GC to exist. ��Ruby GC's base line > is that C Strings are owned by Ruby Strings, and that line should not be > broken just because you are sure by a heuristic approach. So basically there is no way to wrap, for example, http://library.gnome.org/devel/gio/stable/GFile.html#g-file-load-contents efficiently. I���ll always have to copy the loaded contents into a new Ruby String and then free the returned char * contents. (Unless I write a utility method like VALUE cstr_to_rval_own(char *string, gsize length) { NEWOBJ(str, struct RString); OBJSETUP(str, rb_cString, T_STRING); str->ptr = string; str->len = length; str->aux.capa = length; return (VALUE)str; } (which needs a separate 1.9.* implementation, as aux doesn���t exist as such anymore.))