From: ts Date: 2003-12-07T20:56:50+09:00 Subject: Re: creating new Ruby strings in C >>>>> "C" == Charles Mills writes: C> Is it possible for RSTRING(str)->ptr to reference a C string or part of a C> C buffer with out eventually calling free on ptr (and without stopping C> the gc)? yes, and no : see mmap mmap can be seen as a delegator : in some case, it just create a String object and call the corresponding String method, but it's very carefull about the gc C> What are str_new3 and str_new4 used for? shared string used for example in string and regexp. Just an example with regexp a = "aaa" /.*/ =~ a a << "b" After the match, $~ and `a' "share" internally the same string, but the variable `a' is marked "copy-on-write". When ruby want to modify `a', it first duplicate the string and make the modification. Guy Decoux