Is it safe so set the length of a String Buffer like so:
{
	VALUE str_buf;
	long len = len_of_ext_data_source;
	unsigned char *buf = ptr_to_ext_data_source;

	str_buf = rb_str_buf_new(len);	
	/* bug: Dangerous to set Ruby String fields directly? */
	MEMCPY(RSTRING(str_buf)->ptr, buf, unsigned char, len);
	RSTRING(str_buf)->len = len;
	return str_buf;
}
Where len is the length of some buffer and buf is a pointer to that 
buffer.
-Charlie