Skip to content

Commit

Permalink
new API function mrb_string_value_len()
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Dec 1, 2015
1 parent 0701236 commit 36fabe1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/mruby/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ MRB_API mrb_value mrb_check_string_type(mrb_state *mrb, mrb_value str);
MRB_API mrb_value mrb_str_buf_new(mrb_state *mrb, size_t capa);

MRB_API const char *mrb_string_value_cstr(mrb_state *mrb, mrb_value *ptr);
MRB_API const char *mrb_string_value_ptr(mrb_state *mrb, mrb_value ptr);
MRB_API const char *mrb_string_value_ptr(mrb_state *mrb, mrb_value str);
MRB_API mrb_int mrb_string_value_len(mrb_state *mrb, mrb_value str);

/*
* Duplicates a string object.
Expand Down
7 changes: 7 additions & 0 deletions src/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,13 @@ mrb_string_value_ptr(mrb_state *mrb, mrb_value ptr)
return RSTRING_PTR(str);
}

MRB_API mrb_int
mrb_string_value_len(mrb_state *mrb, mrb_value ptr)
{
mrb_value str = mrb_str_to_str(mrb, ptr);
return RSTRING_LEN(str);
}

void
mrb_noregexp(mrb_state *mrb, mrb_value self)
{
Expand Down

0 comments on commit 36fabe1

Please sign in to comment.