diff options
author | Nicholas Clark <nick@ccl4.org> | 2006-11-06 22:21:05 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2006-11-06 22:21:05 +0000 |
commit | 9c6bc640227cd4fa081b32554378abe794cacfc0 (patch) | |
tree | a489754dba985d4d26d03fd993aed577a36e9a83 | |
parent | 797c717188459bd306f22db4f33d8350f22fec7c (diff) | |
download | perl-9c6bc640227cd4fa081b32554378abe794cacfc0.tar.gz |
assert() that SvPV_set() isn't used on arrays.
p4raw-id: //depot/perl@29221
-rw-r--r-- | av.c | 18 | ||||
-rw-r--r-- | cop.h | 2 | ||||
-rw-r--r-- | mathoms.c | 2 | ||||
-rw-r--r-- | pp.c | 4 | ||||
-rw-r--r-- | pp_ctl.c | 4 | ||||
-rw-r--r-- | pp_hot.c | 4 | ||||
-rw-r--r-- | pp_sort.c | 4 | ||||
-rw-r--r-- | sv.c | 4 | ||||
-rw-r--r-- | sv.h | 1 |
9 files changed, 22 insertions, 21 deletions
@@ -95,7 +95,7 @@ Perl_av_extend(pTHX_ AV *av, I32 key) tmp = AvARRAY(av) - AvALLOC(av); Move(AvARRAY(av), AvALLOC(av), AvFILLp(av)+1, SV*); AvMAX(av) += tmp; - SvPV_set(av, (char*)AvALLOC(av)); + AvARRAY(av) = AvALLOC(av); if (AvREAL(av)) { while (tmp) ary[--tmp] = &PL_sv_undef; @@ -171,7 +171,7 @@ Perl_av_extend(pTHX_ AV *av, I32 key) ary[--tmp] = &PL_sv_undef; } - SvPV_set(av, (char*)AvALLOC(av)); + AvARRAY(av) = AvALLOC(av); AvMAX(av) = newmax; } } @@ -367,7 +367,7 @@ Perl_newAV(pTHX) sv_upgrade((SV *)av, SVt_PVAV); /* sv_upgrade does AvREAL_only() */ AvALLOC(av) = 0; - SvPV_set(av, NULL); + AvARRAY(av) = NULL; AvMAX(av) = AvFILLp(av) = -1; return av; } @@ -394,7 +394,7 @@ Perl_av_make(pTHX_ register I32 size, register SV **strp) register I32 i; Newx(ary,size,SV*); AvALLOC(av) = ary; - SvPV_set(av, (char*)ary); + AvARRAY(av) = ary; AvFILLp(av) = AvMAX(av) = size - 1; for (i = 0; i < size; i++) { assert (*strp); @@ -452,7 +452,7 @@ Perl_av_clear(pTHX_ register AV *av) extra = AvARRAY(av) - AvALLOC(av); if (extra) { AvMAX(av) += extra; - SvPV_set(av, (char*)AvALLOC(av)); + AvARRAY(av) = AvALLOC(av); } AvFILLp(av) = -1; @@ -482,7 +482,7 @@ Perl_av_undef(pTHX_ register AV *av) } Safefree(AvALLOC(av)); AvALLOC(av) = NULL; - SvPV_set(av, NULL); + AvARRAY(av) = NULL; AvMAX(av) = AvFILLp(av) = -1; } @@ -618,7 +618,7 @@ Perl_av_unshift(pTHX_ register AV *av, register I32 num) AvMAX(av) += i; AvFILLp(av) += i; - SvPV_set(av, (char*)(AvARRAY(av) - i)); + AvARRAY(av) = AvARRAY(av) - i; } if (num) { register SV **ary; @@ -637,7 +637,7 @@ Perl_av_unshift(pTHX_ register AV *av, register I32 num) /* Make extra elements into a buffer */ AvMAX(av) -= slide; AvFILLp(av) -= slide; - SvPV_set(av, (char*)(AvARRAY(av) + slide)); + AvARRAY(av) = AvARRAY(av) + slide; } } @@ -681,7 +681,7 @@ Perl_av_shift(pTHX_ register AV *av) retval = *AvARRAY(av); if (AvREAL(av)) *AvARRAY(av) = &PL_sv_undef; - SvPV_set(av, (char*)(AvARRAY(av) + 1)); + AvARRAY(av) = AvARRAY(av) + 1; AvMAX(av)--; AvFILLp(av)--; if (SvSMAGICAL(av)) @@ -320,7 +320,7 @@ struct block_sub { #define CLEAR_ARGARRAY(ary) \ STMT_START { \ AvMAX(ary) += AvARRAY(ary) - AvALLOC(ary); \ - SvPV_set(ary, (char*)AvALLOC(ary)); \ + AvARRAY(ary) = AvALLOC(ary); \ AvFILLp(ary) = -1; \ } STMT_END @@ -554,7 +554,7 @@ Perl_av_fake(pTHX_ register I32 size, register SV **strp) AvALLOC(av) = ary; Copy(strp,ary,size,SV*); AvREIFY_only(av); - SvPV_set(av, (char*)ary); + AvARRAY(av) = ary; AvFILLp(av) = size - 1; AvMAX(av) = size - 1; while (size--) { @@ -4276,7 +4276,7 @@ PP(pp_splice) *dst-- = *src--; } dst = AvARRAY(ary); - SvPV_set(ary, (char*)(AvARRAY(ary) - diff)); /* diff is negative */ + AvARRAY(ary) = AvARRAY(ary) - diff; /* diff is negative */ AvMAX(ary) += diff; } else { @@ -4312,7 +4312,7 @@ PP(pp_splice) dst = src - diff; Move(src, dst, offset, SV*); } - SvPV_set(ary, (char*)(AvARRAY(ary) - diff));/* diff is positive */ + AvARRAY(ary) = AvARRAY(ary) - diff;/* diff is positive */ AvMAX(ary) += diff; AvFILLp(ary) += diff; } @@ -2450,13 +2450,13 @@ PP(pp_goto) SV **ary = AvALLOC(av); if (AvARRAY(av) != ary) { AvMAX(av) += AvARRAY(av) - AvALLOC(av); - SvPV_set(av, (char*)ary); + AvARRAY(av) = ary; } if (items >= AvMAX(av) + 1) { AvMAX(av) = items - 1; Renew(ary,items+1,SV*); AvALLOC(av) = ary; - SvPV_set(av, (char*)ary); + AvARRAY(av) = ary; } } ++mark; @@ -2856,13 +2856,13 @@ try_autoload: SV **ary = AvALLOC(av); if (AvARRAY(av) != ary) { AvMAX(av) += AvARRAY(av) - AvALLOC(av); - SvPV_set(av, (char*)ary); + AvARRAY(av) = ary; } if (items > AvMAX(av) + 1) { AvMAX(av) = items - 1; Renew(ary,items,SV*); AvALLOC(av) = ary; - SvPV_set(av, (char*)ary); + AvARRAY(av) = ary; } } Copy(MARK,AvARRAY(av),items,SV*); @@ -1770,12 +1770,12 @@ S_sortcv_stacked(pTHX_ SV *a, SV *b) SV** ary = AvALLOC(av); if (AvARRAY(av) != ary) { AvMAX(av) += AvARRAY(av) - AvALLOC(av); - SvPV_set(av, (char*)ary); + AvARRAY(av) = ary; } if (AvMAX(av) < 1) { AvMAX(av) = 1; Renew(ary,2,SV*); - SvPV_set(av, (char*)ary); + AvARRAY(av) = ary; } } AvFILLp(av) = 1; @@ -10060,7 +10060,7 @@ Perl_sv_dup(pTHX_ const SV *sstr, CLONE_PARAMS* param) src_ary = AvARRAY((AV*)sstr); Newxz(dst_ary, AvMAX((AV*)sstr)+1, SV*); ptr_table_store(PL_ptr_table, src_ary, dst_ary); - SvPV_set(dstr, (char*)dst_ary); + AvARRAY((AV*)dstr) = dst_ary; AvALLOC((AV*)dstr) = dst_ary; if (AvREAL((AV*)sstr)) { while (items-- > 0) @@ -10076,7 +10076,7 @@ Perl_sv_dup(pTHX_ const SV *sstr, CLONE_PARAMS* param) } } else { - SvPV_set(dstr, NULL); + AvARRAY((AV*)dstr) = NULL; AvALLOC((AV*)dstr) = (SV**)NULL; } break; @@ -1239,6 +1239,7 @@ the scalar's value cannot change unless written to. (((XPVNV*)SvANY(sv))->xnv_u.xnv_nv = (val)); } STMT_END #define SvPV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_PV); \ + assert(SvTYPE(sv) != SVt_PVAV); \ assert(SvTYPE(sv) != SVt_PVHV); \ assert(!isGV_with_GP(sv)); \ ((sv)->sv_u.svu_pv = (val)); } STMT_END |