diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-09-29 05:15:33 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-09-29 05:15:33 +0000 |
commit | 30116ff8c286c91090722f4d6aada2cc47fcae7e (patch) | |
tree | 020bde425e972437d6945522f1d628236286e106 /array.c | |
parent | c0e71a8a97b907ab934d02d3cc4d9e55538a2e5f (diff) |
* array.c (rb_ary_delete): comparison may change the capacity.
[ruby-dev:24348]
* array.c (rb_ary_fill): fill should honor length argument.
[ruby-dev:24346]
* array.c (rb_ary_replace): should not use ptr from shared array.
[ruby-dev:24345]
* ext/socket/socket.c (s_accept): don't retry for EWOULDBLOCK.
[ruby-talk:113807]
* array.c (flatten): element size might change during comparison.
[ruby-dev:24343]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6972 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r-- | array.c | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -1961,8 +1961,7 @@ rb_ary_delete(ary, item) if (rb_equal(e, item)) continue; if (i1 != i2) { - if (RARRAY(ary)->len < i2) break; - RARRAY(ary)->ptr[i2] = e; + rb_ary_store(ary, i2, e); } i2++; } @@ -1973,12 +1972,13 @@ rb_ary_delete(ary, item) return Qnil; } - if (RARRAY(ary)->len > i2) + if (RARRAY(ary)->len > i2) { RARRAY(ary)->len = i2; - if (i2 * 2 < RARRAY(ary)->aux.capa && + if (i2 * 2 < RARRAY(ary)->aux.capa && RARRAY(ary)->aux.capa > ARY_DEFAULT_SIZE) { - REALLOC_N(RARRAY(ary)->ptr, VALUE, i2 * 2); - RARRAY(ary)->aux.capa = i2 * 2; + REALLOC_N(RARRAY(ary)->ptr, VALUE, i2 * 2); + RARRAY(ary)->aux.capa = i2 * 2; + } } return item; @@ -2276,8 +2276,8 @@ rb_ary_replace(copy, orig) shared = ary_make_shared(orig); if (RARRAY(copy)->ptr && !FL_TEST(copy, ELTS_SHARED)) free(RARRAY(copy)->ptr); - RARRAY(copy)->ptr = RARRAY(shared)->ptr; - RARRAY(copy)->len = RARRAY(shared)->len; + RARRAY(copy)->ptr = RARRAY(orig)->ptr; + RARRAY(copy)->len = RARRAY(orig)->len; RARRAY(copy)->aux.shared = shared; FL_SET(copy, ELTS_SHARED); @@ -2386,7 +2386,7 @@ rb_ary_fill(argc, argv, ary) VALUE v; long i; - for (i=beg; i<RARRAY(ary)->len; i++) { + for (i=beg; i<end; i++) { v = rb_yield(LONG2NUM(i)); if (i>=RARRAY(ary)->len) break; RARRAY(ary)->ptr[i] = v; @@ -2996,7 +2996,7 @@ flatten(ary, idx, ary2, memo) while (i < lim) { VALUE tmp; - tmp = rb_check_array_type(RARRAY(ary)->ptr[i]); + tmp = rb_check_array_type(rb_ary_elt(ary, i)); if (!NIL_P(tmp)) { n = flatten(ary, i, tmp, memo); i += n; lim += n; |