ext/-test-/string/capacity.c
raw| 1 | #include "ruby.h" |
| 2 | #include "internal/string.h" |
| 3 | |
| 4 | static VALUE |
| 5 | bug_str_capacity(VALUE klass, VALUE str) |
| 6 | { |
| 7 | if (!STR_EMBED_P(str) && STR_SHARED_P(str)) { |
| 8 | return INT2FIX(0); |
| 9 | } |
| 10 | |
| 11 | return LONG2FIX(rb_str_capacity(str)); |
| 12 | } |
| 13 | |
| 14 | void |
| 15 | Init_string_capacity(VALUE klass) |
| 16 | { |
| 17 | rb_define_singleton_method(klass, "capacity", bug_str_capacity, 1); |
| 18 | } |