X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=av.c;h=a4d6ea2d06a056a28e30369e52e878d6849cb5d6;hb=6f7a7d3eeb6b7da414c3496d3eb5a7c4f5127201;hp=c597ea2d1a6564ac5e605ecb722d07aebcce95a1;hpb=4ac71550d23cca4632a2bcdfcb1d83a6bf705e45;p=p5sagit%2Fp5-mst-13.2.git diff --git a/av.c b/av.c index c597ea2..a4d6ea2 100644 --- a/av.c +++ b/av.c @@ -35,8 +35,8 @@ Perl_av_reify(pTHX_ AV *av) if (AvREAL(av)) return; #ifdef DEBUGGING - if (SvTIED_mg((const SV *)av, PERL_MAGIC_tied) && ckWARN_d(WARN_DEBUGGING)) - Perl_warner(aTHX_ packWARN(WARN_DEBUGGING), "av_reify called on tied array"); + if (SvTIED_mg((const SV *)av, PERL_MAGIC_tied)) + Perl_ck_warner_d(aTHX_ packWARN(WARN_DEBUGGING), "av_reify called on tied array"); #endif key = AvMAX(av) + 1; while (key > AvFILLp(av) + 1) @@ -404,8 +404,14 @@ Perl_av_make(pTHX_ register I32 size, register SV **strp) AvFILLp(av) = AvMAX(av) = size - 1; for (i = 0; i < size; i++) { assert (*strp); + + /* Don't let sv_setsv swipe, since our source array might + have multiple references to the same temp scalar (e.g. + from a list slice) */ + ary[i] = newSV(0); - sv_setsv(ary[i], *strp); + sv_setsv_flags(ary[i], *strp, + SV_GMAGIC|SV_DO_COW_SVSETSV|SV_NOSTEAL); strp++; } } @@ -431,8 +437,8 @@ Perl_av_clear(pTHX_ register AV *av) assert(SvTYPE(av) == SVt_PVAV); #ifdef DEBUGGING - if (SvREFCNT(av) == 0 && ckWARN_d(WARN_DEBUGGING)) { - Perl_warner(aTHX_ packWARN(WARN_DEBUGGING), "Attempt to clear deleted array"); + if (SvREFCNT(av) == 0) { + Perl_ck_warner_d(aTHX_ packWARN(WARN_DEBUGGING), "Attempt to clear deleted array"); } #endif @@ -527,7 +533,8 @@ Perl_av_create_and_push(pTHX_ AV **const avp, SV *const val) =for apidoc av_push Pushes an SV onto the end of the array. The array will grow automatically -to accommodate the addition. +to accommodate the addition. Like C, this takes ownership of one +reference count. =cut */