summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2006-11-06 22:21:05 +0000
committerNicholas Clark <nick@ccl4.org>2006-11-06 22:21:05 +0000
commit9c6bc640227cd4fa081b32554378abe794cacfc0 (patch)
treea489754dba985d4d26d03fd993aed577a36e9a83
parent797c717188459bd306f22db4f33d8350f22fec7c (diff)
downloadperl-9c6bc640227cd4fa081b32554378abe794cacfc0.tar.gz
assert() that SvPV_set() isn't used on arrays.
p4raw-id: //depot/perl@29221
-rw-r--r--av.c18
-rw-r--r--cop.h2
-rw-r--r--mathoms.c2
-rw-r--r--pp.c4
-rw-r--r--pp_ctl.c4
-rw-r--r--pp_hot.c4
-rw-r--r--pp_sort.c4
-rw-r--r--sv.c4
-rw-r--r--sv.h1
9 files changed, 22 insertions, 21 deletions
diff --git a/av.c b/av.c
index e4ab13a7d2..22eb6716f2 100644
--- a/av.c
+++ b/av.c
@@ -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))
diff --git a/cop.h b/cop.h
index e9d786fcfc..d75d2f1194 100644
--- a/cop.h
+++ b/cop.h
@@ -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
diff --git a/mathoms.c b/mathoms.c
index d15aec95f4..79a3c319b4 100644
--- a/mathoms.c
+++ b/mathoms.c
@@ -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--) {
diff --git a/pp.c b/pp.c
index 229f703417..43e400bb6e 100644
--- a/pp.c
+++ b/pp.c
@@ -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;
}
diff --git a/pp_ctl.c b/pp_ctl.c
index 7a8da0d5ce..6bc8e780f2 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -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;
diff --git a/pp_hot.c b/pp_hot.c
index d1873b2a32..d2e8e87b18 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -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*);
diff --git a/pp_sort.c b/pp_sort.c
index dfcdac4bfd..6899ff491b 100644
--- a/pp_sort.c
+++ b/pp_sort.c
@@ -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;
diff --git a/sv.c b/sv.c
index 8aaa792db3..66d29e480f 100644
--- a/sv.c
+++ b/sv.c
@@ -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;
diff --git a/sv.h b/sv.h
index 0937fbdcc9..eabc2bf59b 100644
--- a/sv.h
+++ b/sv.h
@@ -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