X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=av.c;h=f45a3ea63f439184da2395ce791d94b7aa765a9e;hb=923e061dc2258fcbb7b78473a6ebb8391a3e8068;hp=7bd19eea5a72a71cefa0969a1cc86f528df9c753;hpb=ad64d0ecd555e97c5a216efca1ec5a96b7fd0b34;p=p5sagit%2Fp5-mst-13.2.git diff --git a/av.c b/av.c index 7bd19ee..f45a3ea 100644 --- a/av.c +++ b/av.c @@ -9,8 +9,10 @@ */ /* - * "...for the Entwives desired order, and plenty, and peace (by which they - * meant that things should remain where they had set them)." --Treebeard + * '...for the Entwives desired order, and plenty, and peace (by which they + * meant that things should remain where they had set them).' --Treebeard + * + * [p.476 of _The Lord of the Rings_, III/iv: "Treebeard"] */ /* @@ -134,7 +136,7 @@ Perl_av_extend(pTHX_ AV *av, I32 key) the current lazy system of only writing to it if our caller has a need for more space. NWC */ newmax = Perl_safesysmalloc_size((void*)AvALLOC(av)) / - sizeof(SV*) - 1; + sizeof(const SV *) - 1; if (key <= newmax) goto resized; @@ -145,20 +147,21 @@ Perl_av_extend(pTHX_ AV *av, I32 key) #if defined(STRANGE_MALLOC) || defined(MYMALLOC) Renew(AvALLOC(av),newmax+1, SV*); #else - bytes = (newmax + 1) * sizeof(SV*); + bytes = (newmax + 1) * sizeof(const SV *); #define MALLOC_OVERHEAD 16 itmp = MALLOC_OVERHEAD; while ((MEM_SIZE)(itmp - MALLOC_OVERHEAD) < bytes) itmp += itmp; itmp -= MALLOC_OVERHEAD; - itmp /= sizeof(SV*); + itmp /= sizeof(const SV *); assert(itmp > newmax); newmax = itmp - 1; assert(newmax >= AvMAX(av)); Newx(ary, newmax+1, SV*); Copy(AvALLOC(av), ary, AvMAX(av)+1, SV*); if (AvMAX(av) > 64) - offer_nice_chunk(AvALLOC(av), (AvMAX(av)+1) * sizeof(SV*)); + offer_nice_chunk(AvALLOC(av), + (AvMAX(av)+1) * sizeof(const SV *)); else Safefree(AvALLOC(av)); AvALLOC(av) = ary; @@ -341,7 +344,7 @@ Perl_av_store(pTHX_ register AV *av, I32 key, SV *val) } if (SvREADONLY(av) && key >= AvFILL(av)) - Perl_croak(aTHX_ PL_no_modify); + Perl_croak(aTHX_ "%s", PL_no_modify); if (!AvREAL(av) && AvREIFY(av)) av_reify(av); @@ -434,7 +437,7 @@ Perl_av_clear(pTHX_ register AV *av) #endif if (SvREADONLY(av)) - Perl_croak(aTHX_ PL_no_modify); + Perl_croak(aTHX_ "%s", PL_no_modify); /* Give any tie a chance to cleanup first */ if (SvRMAGICAL(av)) { @@ -524,7 +527,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 */ @@ -539,7 +543,7 @@ Perl_av_push(pTHX_ register AV *av, SV *val) assert(SvTYPE(av) == SVt_PVAV); if (SvREADONLY(av)) - Perl_croak(aTHX_ PL_no_modify); + Perl_croak(aTHX_ "%s", PL_no_modify); if ((mg = SvTIED_mg((const SV *)av, PERL_MAGIC_tied))) { dSP; @@ -578,7 +582,7 @@ Perl_av_pop(pTHX_ register AV *av) assert(SvTYPE(av) == SVt_PVAV); if (SvREADONLY(av)) - Perl_croak(aTHX_ PL_no_modify); + Perl_croak(aTHX_ "%s", PL_no_modify); if ((mg = SvTIED_mg((const SV *)av, PERL_MAGIC_tied))) { dSP; PUSHSTACKi(PERLSI_MAGIC); @@ -647,7 +651,7 @@ Perl_av_unshift(pTHX_ register AV *av, register I32 num) assert(SvTYPE(av) == SVt_PVAV); if (SvREADONLY(av)) - Perl_croak(aTHX_ PL_no_modify); + Perl_croak(aTHX_ "%s", PL_no_modify); if ((mg = SvTIED_mg((const SV *)av, PERL_MAGIC_tied))) { dSP; @@ -720,7 +724,7 @@ Perl_av_shift(pTHX_ register AV *av) assert(SvTYPE(av) == SVt_PVAV); if (SvREADONLY(av)) - Perl_croak(aTHX_ PL_no_modify); + Perl_croak(aTHX_ "%s", PL_no_modify); if ((mg = SvTIED_mg((const SV *)av, PERL_MAGIC_tied))) { dSP; PUSHSTACKi(PERLSI_MAGIC); @@ -851,7 +855,7 @@ Perl_av_delete(pTHX_ AV *av, I32 key, I32 flags) assert(SvTYPE(av) == SVt_PVAV); if (SvREADONLY(av)) - Perl_croak(aTHX_ PL_no_modify); + Perl_croak(aTHX_ "%s", PL_no_modify); if (SvRMAGICAL(av)) { const MAGIC * const tied_magic