void
Perl_av_extend(pTHX_ AV *av, I32 key)
{
- MAGIC *mg;
- if ((mg = SvTIED_mg((SV*)av, PERL_MAGIC_tied))) {
+ MAGIC * const mg = SvTIED_mg((SV*)av, PERL_MAGIC_tied);
+ if (mg) {
dSP;
ENTER;
SAVETMPS;
while (tmp)
ary[--tmp] = &PL_sv_undef;
}
-
if (key > AvMAX(av) - 10) {
newmax = key + AvMAX(av);
goto resize;
if (tied_magic && key < 0) {
/* Handle negative array indices 20020222 MJD */
- SV **negative_indices_glob =
+ SV * const * const negative_indices_glob =
hv_fetch(SvSTASH(SvRV(SvTIED_obj((SV *)av,
tied_magic))),
NEGATIVE_INDICES_VAR, 16, 0);
}
else if (AvREIFY(av)
&& (!AvARRAY(av)[key] /* eg. @_ could have freed elts */
- || SvTYPE(AvARRAY(av)[key]) == SVTYPEMASK)) {
+ || SvIS_FREED(AvARRAY(av)[key]))) {
AvARRAY(av)[key] = &PL_sv_undef; /* 1/2 reify */
goto emptyness;
}
/* Handle negative array indices 20020222 MJD */
if (key < 0) {
unsigned adjust_index = 1;
- SV **negative_indices_glob =
+ SV * const * const negative_indices_glob =
hv_fetch(SvSTASH(SvRV(SvTIED_obj((SV *)av,
tied_magic))),
NEGATIVE_INDICES_VAR, 16, 0);
AV *
Perl_newAV(pTHX)
{
- register AV *av;
+ register AV * const av = (AV*)NEWSV(3,0);
- av = (AV*)NEWSV(3,0);
sv_upgrade((SV *)av, SVt_PVAV);
/* sv_upgrade does AvREAL_only() */
AvALLOC(av) = 0;
AV *
Perl_av_make(pTHX_ register I32 size, register SV **strp)
{
- register AV *av;
+ register AV * const av = (AV*)NEWSV(8,0);
- av = (AV*)NEWSV(8,0);
sv_upgrade((SV *) av,SVt_PVAV);
/* sv_upgrade does AvREAL_only() */
if (size) { /* "defined" was returning undef for size==0 anyway. */
return av;
}
-AV *
-Perl_av_fake(pTHX_ register I32 size, register SV **strp)
-{
- register AV *av;
- register SV** ary;
-
- av = (AV*)NEWSV(9,0);
- sv_upgrade((SV *)av, SVt_PVAV);
- Newx(ary,size+1,SV*);
- AvALLOC(av) = ary;
- Copy(strp,ary,size,SV*);
- AvREIFY_only(av);
- SvPV_set(av, (char*)ary);
- AvFILLp(av) = size - 1;
- AvMAX(av) = size - 1;
- while (size--) {
- assert (*strp);
- SvTEMP_off(*strp);
- strp++;
- }
- return av;
-}
-
/*
=for apidoc av_clear
return;
if (AvREAL(av)) {
- SV** ary = AvARRAY(av);
+ SV** const ary = AvARRAY(av);
key = AvFILLp(av) + 1;
while (key) {
- SV * sv = ary[--key];
+ SV * const sv = ary[--key];
/* undef the slot before freeing the value, because a
* destructor might try to modify this arrray */
ary[key] = &PL_sv_undef;
if (key < 0) {
unsigned adjust_index = 1;
if (tied_magic) {
- SV **negative_indices_glob =
+ SV * const * const negative_indices_glob =
hv_fetch(SvSTASH(SvRV(SvTIED_obj((SV *)av,
tied_magic))),
NEGATIVE_INDICES_VAR, 16, 0);
if (key < 0) {
unsigned adjust_index = 1;
if (tied_magic) {
- SV **negative_indices_glob =
+ SV * const * const negative_indices_glob =
hv_fetch(SvSTASH(SvRV(SvTIED_obj((SV *)av,
tied_magic))),
NEGATIVE_INDICES_VAR, 16, 0);