From 70b317b9dababf3527deba01544e157f1c87375d Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 22 Jul 2008 07:48:00 +0000 Subject: * 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@18156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- string.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'string.c') diff --git a/string.c b/string.c index 387786fe07..72240b8506 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) { -- cgit v1.2.3