> -----Original Message----- > From: Yukihiro Matsumoto [mailto:matz / ruby-lang.org] > Sent: Tuesday, September 13, 2005 5:13 PM > To: ruby-talk ML > Subject: Re: Question on StringValuePtr, rb_str_dup > > > Hi, > > In message "Re: Question on StringValuePtr, rb_str_dup" > on Wed, 14 Sep 2005 06:38:44 +0900, "Berger, Daniel" > <Daniel.Berger / qwest.com> writes: > > |I'm having a hard time preserving a string. Essentially, what's > |happening is that even though I'm dup'ing the original > string, after I > |pass it a C function that modifies the receiver, both the original > |string *and* the dup appear to be affected. > > Because plain duplication shares internal memory region. You > have to call rb_str_modify() before modifying a string. > > matz. Good to know. Thanks! Dan