Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #1836 from monaka/pr-use-mrb_str_new_cstr

Use mrb_str_new_cstr() instead of mrb_str_new() with strlen().
  • Loading branch information...
commit 5f787b0cdf761ddc3511b98ea2e5c7c1bd882694 2 parents 4f27089 + 40f57f7
Yukihiro "Matz" Matsumoto matz authored
Showing with 5 additions and 5 deletions.
  1. +1 −1  mrbgems/mruby-bin-mruby/tools/mruby/mruby.c
  2. +4 −4 src/codegen.c
2  mrbgems/mruby-bin-mruby/tools/mruby/mruby.c
View
@@ -193,7 +193,7 @@ main(int argc, char **argv)
ARGV = mrb_ary_new_capa(mrb, args.argc);
for (i = 0; i < args.argc; i++) {
- mrb_ary_push(mrb, ARGV, mrb_str_new(mrb, args.argv[i], strlen(args.argv[i])));
+ mrb_ary_push(mrb, ARGV, mrb_str_new_cstr(mrb, args.argv[i]));
}
mrb_define_global_const(mrb, "ARGV", ARGV);
8 src/codegen.c
View
@@ -2107,7 +2107,7 @@ codegen(codegen_scope *s, node *tree, int val)
char *p2 = (char*)tree->cdr;
int ai = mrb_gc_arena_save(s->mrb);
int sym = new_sym(s, mrb_intern_lit(s->mrb, REGEXP_CLASS));
- int off = new_lit(s, mrb_str_new(s->mrb, p1, strlen(p1)));
+ int off = new_lit(s, mrb_str_new_cstr(s->mrb, p1));
int argc = 1;
genop(s, MKOP_A(OP_OCLASS, cursp()));
@@ -2116,7 +2116,7 @@ codegen(codegen_scope *s, node *tree, int val)
genop(s, MKOP_ABx(OP_STRING, cursp(), off));
if (p2) {
push();
- off = new_lit(s, mrb_str_new(s->mrb, p2, strlen(p2)));
+ off = new_lit(s, mrb_str_new_cstr(s->mrb, p2));
genop(s, MKOP_ABx(OP_STRING, cursp(), off));
argc++;
pop();
@@ -2153,7 +2153,7 @@ codegen(codegen_scope *s, node *tree, int val)
n = tree->cdr->cdr;
if (n->car) {
p = (char*)n->car;
- off = new_lit(s, mrb_str_new(s->mrb, p, strlen(p)));
+ off = new_lit(s, mrb_str_new_cstr(s->mrb, p));
codegen(s, tree->car, VAL);
genop(s, MKOP_ABx(OP_STRING, cursp(), off));
pop();
@@ -2164,7 +2164,7 @@ codegen(codegen_scope *s, node *tree, int val)
int off;
push();
- off = new_lit(s, mrb_str_new(s->mrb, p2, strlen(p2)));
+ off = new_lit(s, mrb_str_new_cstr(s->mrb, p2));
genop(s, MKOP_ABx(OP_STRING, cursp(), off));
argc++;
pop();
Please sign in to comment.
Something went wrong with that request. Please try again.