summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2019-08-07 15:40:44 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2019-08-07 15:52:10 +0900
commit98fc887cb3d9458313cc275c4176d16e95c7c0c2 (patch)
tree8b849e34d9684e3d0e3e72a132ac8d59ee45cb47 /include
parentb8a87bd1115bc7f89e2e6caadb70d868d59b3a81 (diff)
downloadmruby-98fc887cb3d9458313cc275c4176d16e95c7c0c2.tar.gz
mruby-98fc887cb3d9458313cc275c4176d16e95c7c0c2.zip
Reorganize `mrb_string_value_cstr` and related functions.
`mrb_string_value_cstr` and `mrb_string_value_len`: obsolete `mrb_string_cstr`: new function to retrieve NULL terminated C string `RSTRING_CSTR`: wrapper macro of `mrb_string_cstr`
Diffstat (limited to 'include')
-rw-r--r--include/mruby/string.h16
1 files changed, 7 insertions, 9 deletions
diff --git a/include/mruby/string.h b/include/mruby/string.h
index d17ac1c1d..7266c9084 100644
--- a/include/mruby/string.h
+++ b/include/mruby/string.h
@@ -96,6 +96,7 @@ struct RString {
#define RSTRING_CAPA(s) RSTR_CAPA(RSTRING(s))
#define RSTRING_END(s) (RSTRING_PTR(s) + RSTRING_LEN(s))
MRB_API mrb_int mrb_str_strlen(mrb_state*, struct RString*);
+#define RSTRING_CSTR(mrb,s) mrb_string_cstr(mrb, s)
#define MRB_STR_SHARED 1
#define MRB_STR_FSHARED 2
@@ -337,16 +338,13 @@ MRB_API mrb_value mrb_string_type(mrb_state *mrb, mrb_value str);
MRB_API mrb_value mrb_str_new_capa(mrb_state *mrb, size_t capa);
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);
+/* NULL terminated C string from mrb_value */
+MRB_API const char *mrb_string_cstr(mrb_state *mrb, mrb_value str);
+/* NULL terminated C string from mrb_value; `str` will be updated */
+MRB_API const char *mrb_string_value_cstr(mrb_state *mrb, mrb_value *str);
+/* obslete: use RSTRING_PTR() */
MRB_API const char *mrb_string_value_ptr(mrb_state *mrb, mrb_value str);
-/*
- * Returns the length of the Ruby string.
- *
- *
- * @param [mrb_state] mrb The current mruby state.
- * @param [mrb_value] str Ruby string.
- * @return [mrb_int] The length of the passed in Ruby string.
- */
+/* obslete: use RSTRING_LEN() */
MRB_API mrb_int mrb_string_value_len(mrb_state *mrb, mrb_value str);
/*