Skip to content

Instantly share code, notes, and snippets.

@methodmissing
Created June 2, 2009 17:24
Show Gist options
  • Select an option

  • Save methodmissing/122375 to your computer and use it in GitHub Desktop.

Select an option

Save methodmissing/122375 to your computer and use it in GitHub Desktop.
VALUE
rb_str_buf_new(capa)
long capa;
{
VALUE str = str_alloc(rb_cString);
if (capa < STR_BUF_MIN_SIZE) {
capa = STR_BUF_MIN_SIZE;
}
RSTRING(str)->ptr = 0;
RSTRING(str)->len = 0;
RSTRING(str)->aux.capa = capa;
RSTRING(str)->ptr = ALLOC_N(char, capa+1);
RSTRING(str)->ptr[0] = '\0';
return str;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment