From: Paul Brannan Date: 2003-03-19T00:59:26+09:00 Subject: Re: ruby-dev summary 19773-19824 On Tue, Mar 18, 2003 at 09:35:14AM +0900, nobu.nokada@softhome.net wrote: > Paul Brannan wrote: > > Will rb_str2cstr be modified to use StringValuePtr(), or will extensions > > have to change to get non-NULL C-strings from STR2CSTR in 1.8.0? If it > > is not modified, how should extension writers write code to work on both > > 1.6.x and 1.8.0? > > Signatures of rb_str2cstr() and StringValuePtr() are different. > StringValuePtr() requires lvalue in order to get rid of > possibility of dangling pointer, so extensions should change to > use latter. I don't understand. Can you elaborate? > > In what conditions will RSTRING(str)->ptr be NULL? > > An example: > > ' '.dup.rstrip.gsub(/a/, '') Why will this leave ptr NULL? It doesn't seem very obvious from the source (in str_gsub, ptr is set equal to buf, which is allocated with malloc(), which should never return 0 except on error). Paul