diff options
| author | KOBAYASHI Shuji <[email protected]> | 2019-05-06 23:16:03 +0900 |
|---|---|---|
| committer | KOBAYASHI Shuji <[email protected]> | 2019-05-06 23:32:53 +0900 |
| commit | e2604c1550562b6fa507570e817cadf9981e1c82 (patch) | |
| tree | df8e5d193871981b5814ee1b24f5095bb2904b33 /mrbgems/mruby-io/test/mruby_io_test.c | |
| parent | 31cc8573f058e791c9a08735afa72678e5df7a46 (diff) | |
| download | mruby-e2604c1550562b6fa507570e817cadf9981e1c82.tar.gz mruby-e2604c1550562b6fa507570e817cadf9981e1c82.zip | |
Avoid using `mrb_str_to_cstr` if possible
Because it always allocate new string. Replace with the followings:
- Use `RSRING_PTR` if string is guaranteed to be null-terminated.
- Use `mrb_string_value_cstr` or `mrb_get_args("z")` if return value isn't
modified.
Diffstat (limited to 'mrbgems/mruby-io/test/mruby_io_test.c')
| -rw-r--r-- | mrbgems/mruby-io/test/mruby_io_test.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/mrbgems/mruby-io/test/mruby_io_test.c b/mrbgems/mruby-io/test/mruby_io_test.c index 71239a827..3312d6c7e 100644 --- a/mrbgems/mruby-io/test/mruby_io_test.c +++ b/mrbgems/mruby-io/test/mruby_io_test.c @@ -215,11 +215,9 @@ mrb_io_test_mkdtemp(mrb_state *mrb, mrb_value klass) static mrb_value mrb_io_test_rmdir(mrb_state *mrb, mrb_value klass) { - mrb_value str; - char *cp; + const char *cp; - mrb_get_args(mrb, "S", &str); - cp = mrb_str_to_cstr(mrb, str); + mrb_get_args(mrb, "z", &cp); if (rmdir(cp) == -1) { mrb_sys_fail(mrb, "rmdir"); } |
