string_buffer.diff

String#buffer - Kornelius Kalnbach, 03/06/2010 11:49 AM

Download (846 Bytes)

View differences:

string.c (working copy)
3808 3808
    return rb_str_substr(str, 0, 1);
3809 3809
}
3810 3810

  
3811
static VALUE
3812
rb_str_set_buffer(VALUE str, VALUE length)
3813
{
3814
    long size = NUM2LONG(length);
3815
    rb_str_modify(str);
3816
    RESIZE_CAPA(str, size);
3817
    return str;
3818
}
3819

  
3811 3820
/*
3812 3821
 *  call-seq:
3813 3822
 *     str.getbyte(index)          => 0 .. 255
......
7423 7432
    rb_define_method(rb_cString, "clear", rb_str_clear, 0);
7424 7433
    rb_define_method(rb_cString, "chr", rb_str_chr, 0);
7425 7434
    rb_define_method(rb_cString, "getbyte", rb_str_getbyte, 1);
7435
    rb_define_method(rb_cString, "buffer", rb_str_set_buffer, 1);
7426 7436
    rb_define_method(rb_cString, "setbyte", rb_str_setbyte, 2);
7427 7437

  
7428 7438
    rb_define_method(rb_cString, "to_i", rb_str_to_i, -1);