aboutsummaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
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 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)
{