summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/string.c21
1 files changed, 4 insertions, 17 deletions
diff --git a/src/string.c b/src/string.c
index 7a2602928..f5ac7b578 100644
--- a/src/string.c
+++ b/src/string.c
@@ -106,21 +106,6 @@ str_mod_check(mrb_state *mrb, mrb_value str, char *p, mrb_int len)
#define mrb_obj_alloc_string(mrb) ((struct RString*)mrb_obj_alloc((mrb), MRB_TT_STRING, (mrb)->string_class))
-static struct RString*
-str_alloc(mrb_state *mrb, struct RClass *c)
-{
- struct RString* s;
-
- s = mrb_obj_alloc_string(mrb);
-
- s->c = c;
- s->ptr = 0;
- s->len = 0;
- s->aux.capa = 0;
-
- return s;
-}
-
/* char offset to byte offset */
int
mrb_str_offset(mrb_state *mrb, mrb_value str, int pos)
@@ -131,8 +116,9 @@ mrb_str_offset(mrb_state *mrb, mrb_value str, int pos)
static struct RString*
str_new(mrb_state *mrb, const char *p, int len)
{
- struct RString *s = str_alloc(mrb, mrb->string_class);
+ struct RString *s;
+ s = mrb_obj_alloc_string(mrb);
s->len = len;
s->aux.capa = len;
s->ptr = (char *)mrb_malloc(mrb, len+1);
@@ -315,7 +301,7 @@ mrb_str_literal(mrb_state *mrb, mrb_value str)
struct RString *s, *orig;
mrb_shared_string *shared;
- s = str_alloc(mrb, mrb->string_class);
+ s = mrb_obj_alloc_string(mrb);
orig = mrb_str_ptr(str);
if (!(orig->flags & MRB_STR_SHARED)) {
str_make_shared(mrb, mrb_str_ptr(str));
@@ -324,6 +310,7 @@ mrb_str_literal(mrb_state *mrb, mrb_value str)
shared->refcnt++;
s->ptr = shared->ptr;
s->len = shared->len;
+ s->aux.capa = 0;
s->aux.shared = shared;
s->flags |= MRB_STR_SHARED;