зеркало из https://github.com/github/ruby.git
string.c: consider capacity
* string.c (rb_str_resize): should consider the capacity instead of the old length, as pointed out by nagachika. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46413 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
595782b924
Коммит
85bbacbba2
|
@ -1,3 +1,8 @@
|
|||
Thu Jun 12 20:32:28 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* string.c (rb_str_resize): should consider the capacity instead
|
||||
of the old length, as pointed out by nagachika.
|
||||
|
||||
Thu Jun 12 18:31:01 2014 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
|
||||
|
||||
* lib/net/http/responses.rb: added Net::HTTPPermanentRedirect(308)
|
||||
|
|
2
string.c
2
string.c
|
@ -1996,7 +1996,7 @@ rb_str_resize(VALUE str, long len)
|
|||
if (len == slen) return str;
|
||||
str_make_independent_expand(str, len - slen);
|
||||
}
|
||||
else if (slen < len || slen - len > 1024) {
|
||||
else if (slen < len || (RSTRING(str)->as.heap.aux.capa - len) > (len < 1024 ? len : 1024)) {
|
||||
REALLOC_N(RSTRING(str)->as.heap.ptr, char, len + termlen);
|
||||
}
|
||||
else if (len == slen) return str;
|
||||
|
|
Загрузка…
Ссылка в новой задаче