diff options
author | Nicholas Clark <nick@ccl4.org> | 2008-10-29 22:45:15 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2008-10-29 22:45:15 +0000 |
commit | 502c6561fcd473b7da3277363169d75f16ac2f8b (patch) | |
tree | 5b840aca24d5b44969c910e6c97f9edf7e221e48 /sv.c | |
parent | 70d97eb0b44379e6179430e19c4bb4222d3544e9 (diff) | |
download | perl-502c6561fcd473b7da3277363169d75f16ac2f8b.tar.gz |
Eliminate (AV *) casts in *.c.
p4raw-id: //depot/perl@34650
Diffstat (limited to 'sv.c')
-rw-r--r-- | sv.c | 54 |
1 files changed, 28 insertions, 26 deletions
@@ -5078,7 +5078,7 @@ Perl_sv_add_backref(pTHX_ SV *const tsv, SV *const sv) if (mg) { /* Aha. They've got it stowed in magic. Bring it back. */ - av = (AV*)mg->mg_obj; + av = MUTABLE_AV(mg->mg_obj); /* Stop mg_free decreasing the refernce count. */ mg->mg_obj = NULL; /* Stop mg_free even calling the destructor, given that @@ -5096,7 +5096,7 @@ Perl_sv_add_backref(pTHX_ SV *const tsv, SV *const sv) const MAGIC *const mg = SvMAGICAL(tsv) ? mg_find(tsv, PERL_MAGIC_backref) : NULL; if (mg) - av = (AV*)mg->mg_obj; + av = MUTABLE_AV(mg->mg_obj); else { av = newAV(); AvREAL_off(av); @@ -5135,7 +5135,7 @@ S_sv_del_backref(pTHX_ SV *const tsv, SV *const sv) const MAGIC *const mg = SvMAGICAL(tsv) ? mg_find(tsv, PERL_MAGIC_backref) : NULL; if (mg) - av = (AV *)mg->mg_obj; + av = MUTABLE_AV(mg->mg_obj); } if (!av) @@ -5519,11 +5519,11 @@ Perl_sv_clear(pTHX_ register SV *const sv) hv_undef(MUTABLE_HV(sv)); break; case SVt_PVAV: - if (PL_comppad == (AV*)sv) { + if (PL_comppad == MUTABLE_AV(sv)) { PL_comppad = NULL; PL_curpad = NULL; } - av_undef((AV*)sv); + av_undef(MUTABLE_AV(sv)); break; case SVt_PVLV: if (LvTYPE(sv) == 'T') { /* for tie: return HE to pool */ @@ -10084,8 +10084,8 @@ ptr_table_* functions. If this changes, please unmerge ss_dup. */ #define sv_dup_inc(s,t) SvREFCNT_inc(sv_dup(s,t)) #define sv_dup_inc_NN(s,t) SvREFCNT_inc_NN(sv_dup(s,t)) -#define av_dup(s,t) (AV*)sv_dup((const SV *)s,t) -#define av_dup_inc(s,t) (AV*)SvREFCNT_inc(sv_dup((const SV *)s,t)) +#define av_dup(s,t) MUTABLE_AV(sv_dup((const SV *)s,t)) +#define av_dup_inc(s,t) MUTABLE_AV(SvREFCNT_inc(sv_dup((const SV *)s,t))) #define hv_dup(s,t) MUTABLE_HV(sv_dup((const SV *)s,t)) #define hv_dup_inc(s,t) MUTABLE_HV(SvREFCNT_inc(sv_dup((const SV *)s,t))) #define cv_dup(s,t) MUTABLE_CV(sv_dup((SV*)s,t)) @@ -10324,7 +10324,8 @@ Perl_mg_dup(pTHX_ MAGIC *mg, CLONE_PARAMS *const param) if(mg->mg_type == PERL_MAGIC_backref) { /* The backref AV has its reference count deliberately bumped by 1. */ - nmg->mg_obj = SvREFCNT_inc(av_dup_inc((AV*) mg->mg_obj, param)); + nmg->mg_obj + = SvREFCNT_inc(av_dup_inc((const AV *) mg->mg_obj, param)); } else { nmg->mg_obj = (mg->mg_flags & MGf_REFCOUNTED) @@ -10777,16 +10778,16 @@ Perl_sv_dup(pTHX_ const SV *const sstr, CLONE_PARAMS *const param) IoBOTTOM_NAME(dstr) = SAVEPV(IoBOTTOM_NAME(dstr)); break; case SVt_PVAV: - if (AvARRAY((AV*)sstr)) { + if (AvARRAY((const AV *)sstr)) { SV **dst_ary, **src_ary; - SSize_t items = AvFILLp((AV*)sstr) + 1; + SSize_t items = AvFILLp((const AV *)sstr) + 1; - src_ary = AvARRAY((AV*)sstr); - Newxz(dst_ary, AvMAX((AV*)sstr)+1, SV*); + src_ary = AvARRAY((const AV *)sstr); + Newxz(dst_ary, AvMAX((const AV *)sstr)+1, SV*); ptr_table_store(PL_ptr_table, src_ary, dst_ary); - AvARRAY((AV*)dstr) = dst_ary; - AvALLOC((AV*)dstr) = dst_ary; - if (AvREAL((AV*)sstr)) { + AvARRAY(MUTABLE_AV(dstr)) = dst_ary; + AvALLOC((const AV *)dstr) = dst_ary; + if (AvREAL((const AV *)sstr)) { while (items-- > 0) *dst_ary++ = sv_dup_inc(*src_ary++, param); } @@ -10794,14 +10795,14 @@ Perl_sv_dup(pTHX_ const SV *const sstr, CLONE_PARAMS *const param) while (items-- > 0) *dst_ary++ = sv_dup(*src_ary++, param); } - items = AvMAX((AV*)sstr) - AvFILLp((AV*)sstr); + items = AvMAX((const AV *)sstr) - AvFILLp((const AV *)sstr); while (items-- > 0) { *dst_ary++ = &PL_sv_undef; } } else { - AvARRAY((AV*)dstr) = NULL; - AvALLOC((AV*)dstr) = (SV**)NULL; + AvARRAY(MUTABLE_AV(dstr)) = NULL; + AvALLOC((const AV *)dstr) = (SV**)NULL; } break; case SVt_PVHV: @@ -10839,8 +10840,8 @@ Perl_sv_dup(pTHX_ const SV *const sstr, CLONE_PARAMS *const param) /* backref array needs refcnt=2; see sv_add_backref */ daux->xhv_backreferences = saux->xhv_backreferences - ? (AV*) SvREFCNT_inc( - sv_dup_inc((SV*)saux->xhv_backreferences, param)) + ? MUTABLE_AV(SvREFCNT_inc( + sv_dup_inc((SV*)saux->xhv_backreferences, param))) : 0; daux->xhv_mro_meta = saux->xhv_mro_meta @@ -11254,7 +11255,7 @@ Perl_ss_dup(pTHX_ PerlInterpreter *proto_perl, CLONE_PARAMS* param) TOPPTR(nss,ix) = sv_dup_inc(sv, param); i = POPINT(ss,ix); TOPINT(nss,ix) = i; - av = (AV*)POPPTR(ss,ix); + av = (const AV *)POPPTR(ss,ix); TOPPTR(nss,ix) = av_dup_inc(av, param); break; case SAVEt_OP: @@ -12390,7 +12391,7 @@ S_varname(pTHX_ const GV *const gv, const char gvtype, PADOFFSET targ, if (!cv || !CvPADLIST(cv)) return NULL; - av = (AV*)(*av_fetch(CvPADLIST(cv), 0, FALSE)); + av = MUTABLE_AV((*av_fetch(CvPADLIST(cv), 0, FALSE))); sv = *av_fetch(av, targ, FALSE); sv_setpvn(name, SvPV_nolen_const(sv), SvCUR(sv)); } @@ -12485,7 +12486,7 @@ S_find_uninit_var(pTHX_ const OP *const obase, const SV *const uninit_sv, subscript_type = FUV_SUBSCRIPT_HASH; } else { - index = find_array_subscript((AV*)sv, uninit_sv); + index = find_array_subscript((const AV *)sv, uninit_sv); if (index >= 0) subscript_type = FUV_SUBSCRIPT_ARRAY; } @@ -12513,7 +12514,7 @@ S_find_uninit_var(pTHX_ const OP *const obase, const SV *const uninit_sv, if (obase->op_flags & OPf_SPECIAL) { /* lexical array */ if (match) { SV **svp; - AV *av = (AV*)PAD_SV(obase->op_targ); + AV *av = MUTABLE_AV(PAD_SV(obase->op_targ)); if (!av || SvRMAGICAL(av)) break; svp = av_fetch(av, (I32)obase->op_private, FALSE); @@ -12585,7 +12586,7 @@ S_find_uninit_var(pTHX_ const OP *const obase, const SV *const uninit_sv, break; } else { - SV * const * const svp = av_fetch((AV*)sv, SvIV(cSVOPx_sv(kid)), FALSE); + SV * const * const svp = av_fetch(MUTABLE_AV(sv), SvIV(cSVOPx_sv(kid)), FALSE); if (!svp || *svp != uninit_sv) break; } @@ -12607,7 +12608,8 @@ S_find_uninit_var(pTHX_ const OP *const obase, const SV *const uninit_sv, keysv, 0, FUV_SUBSCRIPT_HASH); } else { - const I32 index = find_array_subscript((AV*)sv, uninit_sv); + const I32 index + = find_array_subscript((const AV *)sv, uninit_sv); if (index >= 0) return varname(gv, '@', o->op_targ, NULL, index, FUV_SUBSCRIPT_ARRAY); |