diff options
Diffstat (limited to 'src/string.c')
| -rw-r--r-- | src/string.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/string.c b/src/string.c index 247ee78c2..72e14ede9 100644 --- a/src/string.c +++ b/src/string.c @@ -542,6 +542,29 @@ str_make_shared(mrb_state *mrb, struct RString *orig, struct RString *s) } mrb_value +mrb_str_pool(mrb_state *mrb, mrb_value str) +{ + struct RString *s = (struct RString *)mrb_malloc(mrb, sizeof(struct RString)); + struct RString *orig = mrb_str_ptr(str); + const char *p = RSTR_PTR(orig); + size_t len = (size_t)RSTR_LEN(orig); + + s->tt = MRB_TT_STRING; + s->c = mrb->string_class; + s->flags = 0; + + if (RSTR_NOFREE_P(orig)) { + str_init_nofree(s, p, len); + } + else { + str_init(mrb, s, p, len); + } + RSTR_SET_POOL_FLAG(s); + MRB_SET_FROZEN_FLAG(s); + return mrb_obj_value(s); +} + +mrb_value mrb_str_byte_subseq(mrb_state *mrb, mrb_value str, mrb_int beg, mrb_int len) { struct RString *orig, *s; |
