Remove `mrb_str_buf_new()` and `MRB_STR_BUF_MIN_SIZE`; close
MODIFY
build_config/ArduinoDue.rb
build_config/ArduinoDue.rb
@@ -31,7 +31,6 @@ MRuby::CrossBuild.new("ArduinoDue") do |conf|
#configuration for low memory environment
cc.defines << %w(MRB_HEAP_PAGE_SIZE=64)
cc.defines << %w(KHASH_DEFAULT_SIZE=8)
- cc.defines << %w(MRB_STR_BUF_MIN_SIZE=20)
cc.defines << %w(MRB_GC_STRESS)
#cc.defines << %w(MRB_NO_STDIO) #if you dont need stdio.
#cc.defines << %w(POOL_PAGE_SIZE=1000) #effective only for use with mruby-eval

MODIFY
build_config/RX630.rb
build_config/RX630.rb
@@ -17,7 +17,6 @@ MRuby::CrossBuild.new("RX630") do |conf|
cc.defines << %w(MRB_USE_FLOAT32)
cc.defines << %w(MRB_HEAP_PAGE_SIZE=64)
cc.defines << %w(KHASH_DEFAULT_SIZE=8)
- cc.defines << %w(MRB_STR_BUF_MIN_SIZE=20)
cc.defines << %w(MRB_GC_STRESS)
cc.defines << %w(MRB_NO_STDIO) #if you dont need stdio.
#cc.defines << %w(POOL_PAGE_SIZE=1000) #effective only for use with mruby-eval

MODIFY
build_config/chipKITMax32.rb
build_config/chipKITMax32.rb
@@ -28,7 +28,6 @@ MRuby::CrossBuild.new("chipKITMax32") do |conf|
#configuration for low memory environment
cc.defines << %w(MRB_HEAP_PAGE_SIZE=64)
cc.defines << %w(KHASH_DEFAULT_SIZE=8)
- cc.defines << %w(MRB_STR_BUF_MIN_SIZE=20)
cc.defines << %w(MRB_GC_STRESS)
#cc.defines << %w(MRB_NO_STDIO) #if you dont need stdio.
#cc.defines << %w(POOL_PAGE_SIZE=1000) #effective only for use with mruby-eval

MODIFY
doc/guides/mrbconf.md
doc/guides/mrbconf.md
@@ -159,10 +159,6 @@ largest value of required alignment.
* Specifies default size of khash table bucket.
* Used in `kh_init_ ## name` function.
-`MRB_STR_BUF_MIN_SIZE`
-* Default value is `128`.
-* Specifies initial capacity of `RString` created by `mrb_str_buf_new` function..
-
`MRB_NO_METHOD_CACHE`
* Disable method cache to save memory.

MODIFY
include/mrbconf.h
include/mrbconf.h
/* page size of memory pool */
//#define POOL_PAGE_SIZE 16000
-/* initial minimum size for string buffer */
-//#define MRB_STR_BUF_MIN_SIZE 128
-
/* arena size */
//#define MRB_GC_ARENA_SIZE 100
# define KHASH_DEFAULT_SIZE 16
# endif
-# ifndef MRB_STR_BUF_MIN_SIZE
-# define MRB_STR_BUF_MIN_SIZE 32
-# endif
-
# ifndef MRB_HEAP_PAGE_SIZE
# define MRB_HEAP_PAGE_SIZE 256
# endif

MODIFY
include/mruby/string.h
include/mruby/string.h
@@ -339,7 +339,7 @@ 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);
+#define mrb_str_buf_new(mrb, capa) mrb_str_new_capa(mrb, (capa))
/* NULL terminated C string from mrb_value */
MRB_API const char *mrb_string_cstr(mrb_state *mrb, mrb_value str);

MODIFY
mrbgems/mruby-io/src/file.c
mrbgems/mruby-io/src/file.c
@@ -258,7 +258,7 @@ mrb_file_realpath(mrb_state *mrb, mrb_value klass)
pathname = s;
}
cpath = mrb_locale_from_utf8(RSTRING_CSTR(mrb, pathname), -1);
- result = mrb_str_buf_new(mrb, PATH_MAX);
+ result = mrb_str_new_capa(mrb, PATH_MAX);
if (realpath(cpath, RSTRING_PTR(result)) == NULL) {
mrb_locale_free(cpath);
mrb_sys_fail(mrb, cpath);

MODIFY
mrbgems/mruby-socket/src/socket.c
mrbgems/mruby-socket/src/socket.c
@@ -197,8 +197,8 @@ mrb_addrinfo_getnameinfo(mrb_state *mrb, mrb_value self)
flags = 0;
mrb_get_args(mrb, "|i", &flags);
- host = mrb_str_buf_new(mrb, NI_MAXHOST);
- serv = mrb_str_buf_new(mrb, NI_MAXSERV);
+ host = mrb_str_new_capa(mrb, NI_MAXHOST);
+ serv = mrb_str_new_capa(mrb, NI_MAXSERV);
sastr = mrb_iv_get(mrb, self, MRB_IVSYM(sockaddr));
if (!mrb_string_p(sastr)) {
@@ -254,7 +254,7 @@ sa2addrlist(mrb_state *mrb, const struct sockaddr *sa, socklen_t salen)
return mrb_nil_value();
}
port = ntohs(port);
- host = mrb_str_buf_new(mrb, NI_MAXHOST);
+ host = mrb_str_new_capa(mrb, NI_MAXHOST);
if (getnameinfo(sa, salen, RSTRING_PTR(host), NI_MAXHOST, NULL, 0, NI_NUMERICHOST) == -1)
mrb_sys_fail(mrb, "getnameinfo");
mrb_str_resize(mrb, host, strlen(RSTRING_PTR(host)));
@@ -361,7 +361,7 @@ mrb_basicsocket_recv(mrb_state *mrb, mrb_value self)
mrb_value buf;
mrb_get_args(mrb, "i|i", &maxlen, &flags);
- buf = mrb_str_buf_new(mrb, maxlen);
+ buf = mrb_str_new_capa(mrb, maxlen);
n = recv(socket_fd(mrb, self), RSTRING_PTR(buf), (fsize_t)maxlen, (int)flags);
if (n == -1)
mrb_sys_fail(mrb, "recv");
@@ -378,9 +378,9 @@ mrb_basicsocket_recvfrom(mrb_state *mrb, mrb_value self)
socklen_t socklen;
mrb_get_args(mrb, "i|i", &maxlen, &flags);
- buf = mrb_str_buf_new(mrb, maxlen);
+ buf = mrb_str_new_capa(mrb, maxlen);
socklen = sizeof(struct sockaddr_storage);
- sa = mrb_str_buf_new(mrb, socklen);
+ sa = mrb_str_new_capa(mrb, socklen);
n = recvfrom(socket_fd(mrb, self), RSTRING_PTR(buf), (fsize_t)maxlen, (int)flags, (struct sockaddr *)RSTRING_PTR(sa), &socklen);
if (n == -1)
mrb_sys_fail(mrb, "recvfrom");
@@ -570,7 +570,7 @@ mrb_ipsocket_recvfrom(mrb_state *mrb, mrb_value self)
fd = socket_fd(mrb, self);
flags = 0;
mrb_get_args(mrb, "i|i", &maxlen, &flags);
- buf = mrb_str_buf_new(mrb, maxlen);
+ buf = mrb_str_new_capa(mrb, maxlen);
socklen = sizeof(ss);
n = recvfrom(fd, RSTRING_PTR(buf), (fsize_t)maxlen, (int)flags,
(struct sockaddr *)&ss, &socklen);
@@ -596,7 +596,7 @@ mrb_socket_gethostname(mrb_state *mrb, mrb_value cls)
#else
bufsize = 256;
#endif
- buf = mrb_str_buf_new(mrb, (mrb_int)bufsize);
+ buf = mrb_str_new_capa(mrb, (mrb_int)bufsize);
if (gethostname(RSTRING_PTR(buf), (fsize_t)bufsize) != 0)
mrb_sys_fail(mrb, "gethostname");
mrb_str_resize(mrb, buf, (mrb_int)strlen(RSTRING_PTR(buf)));
@@ -627,7 +627,7 @@ mrb_socket_accept2(mrb_state *mrb, mrb_value klass)
mrb_get_args(mrb, "i", &s0);
socklen = sizeof(struct sockaddr_storage);
- sastr = mrb_str_buf_new(mrb, socklen);
+ sastr = mrb_str_new_capa(mrb, socklen);
s1 = (int)accept(s0, (struct sockaddr *)RSTRING_PTR(sastr), &socklen);
if (s1 == -1) {
mrb_sys_fail(mrb, "accept");
@@ -706,7 +706,7 @@ mrb_socket_sockaddr_un(mrb_state *mrb, mrb_value klass)
if ((size_t)RSTRING_LEN(path) > sizeof(sunp->sun_path) - 1) {
mrb_raisef(mrb, E_ARGUMENT_ERROR, "too long unix socket path (max: %d bytes)", (int)sizeof(sunp->sun_path) - 1);
}
- s = mrb_str_buf_new(mrb, sizeof(struct sockaddr_un));
+ s = mrb_str_new_capa(mrb, sizeof(struct sockaddr_un));
sunp = (struct sockaddr_un *)RSTRING_PTR(s);
#if HAVE_SA_LEN
sunp->sun_len = sizeof(struct sockaddr_un);

MODIFY
src/string.c
src/string.c
@@ -175,19 +175,6 @@ mrb_str_new_capa(mrb_state *mrb, size_t capa)
return mrb_obj_value(s);
}
-#ifndef MRB_STR_BUF_MIN_SIZE
-# define MRB_STR_BUF_MIN_SIZE 128
-#endif
-
-MRB_API mrb_value
-mrb_str_buf_new(mrb_state *mrb, size_t capa)
-{
- if (capa < MRB_STR_BUF_MIN_SIZE) {
- capa = MRB_STR_BUF_MIN_SIZE;
- }
- return mrb_str_new_capa(mrb, capa);
-}
-
static void
resize_capa(mrb_state *mrb, struct RString *s, size_t capacity)
{

Remove `mrb_str_buf_new()` and `MRB_STR_BUF_MIN_SIZE`; close #5171