summaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-07-22 07:48:00 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-07-22 07:48:00 +0000
commit4ab0b9959602363ebff6101729ea704280c049a1 (patch)
treeb1949c7c1e76b46a4c6adf172ac5af6e20d62f31 /string.c
parentf00a72d3662b1553c0463d234238b8526fdedf66 (diff)
downloadruby-4ab0b9959602363ebff6101729ea704280c049a1.tar.gz
ruby-4ab0b9959602363ebff6101729ea704280c049a1.tar.xz
ruby-4ab0b9959602363ebff6101729ea704280c049a1.zip
* include/ruby/intern.h, sprintf.c (rb_str_catf, rb_str_vcatf): new
functions. [ruby-dev:35597] * string.c (rb_str_capacity): new function to return the capacity. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/string.c b/string.c
index 387786fe0..72240b850 100644
--- a/string.c
+++ b/string.c
@@ -343,6 +343,20 @@ str_frozen_check(VALUE s)
}
}
+size_t
+rb_str_capacity(VALUE str)
+{
+ if (STR_EMBED_P(str)) {
+ return RSTRING_EMBED_LEN_MAX;
+ }
+ else if (STR_NOCAPA_P(str)) {
+ return RSTRING(str)->as.heap.len;
+ }
+ else {
+ return RSTRING(str)->as.heap.aux.capa;
+ }
+}
+
static inline VALUE
str_alloc(VALUE klass)
{