summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--av.c8
-rw-r--r--embed.fnc1
-rw-r--r--embed.h2
-rw-r--r--global.sym1
-rw-r--r--gv.c4
-rw-r--r--hv.c7
-rw-r--r--mathoms.c4
-rw-r--r--op.c3
-rw-r--r--pad.c11
-rw-r--r--perl.c9
-rw-r--r--pp.c3
-rw-r--r--pp_ctl.c6
-rw-r--r--pp_hot.c3
-rw-r--r--proto.h4
-rw-r--r--sv.c24
-rw-r--r--toke.c6
16 files changed, 48 insertions, 48 deletions
diff --git a/av.c b/av.c
index c6677a9ed8..39b4b7d327 100644
--- a/av.c
+++ b/av.c
@@ -362,9 +362,7 @@ Creates a new AV. The reference count is set to 1.
AV *
Perl_newAV(pTHX)
{
- register AV * const av = (AV*)newSV(0);
-
- sv_upgrade((SV *)av, SVt_PVAV);
+ register AV * const av = (AV*)newSV_type(SVt_PVAV);
/* sv_upgrade does AvREAL_only() */
AvALLOC(av) = 0;
AvARRAY(av) = NULL;
@@ -385,9 +383,7 @@ will have a reference count of 1.
AV *
Perl_av_make(pTHX_ register I32 size, register SV **strp)
{
- register AV * const av = (AV*)newSV(0);
-
- sv_upgrade((SV *) av,SVt_PVAV);
+ register AV * const av = (AV*)newSV_type(SVt_PVAV);
/* sv_upgrade does AvREAL_only() */
if (size) { /* "defined" was returning undef for size==0 anyway. */
register SV** ary;
diff --git a/embed.fnc b/embed.fnc
index 75202585fe..c6a3e0882a 100644
--- a/embed.fnc
+++ b/embed.fnc
@@ -589,6 +589,7 @@ Afpda |SV* |newSVpvf |NN const char* pat|...
Apa |SV* |vnewSVpvf |NN const char* pat|NULLOK va_list* args
Apd |SV* |newSVrv |NN SV* rv|NULLOK const char* classname
Apda |SV* |newSVsv |NULLOK SV* old
+Apda |SV* |newSV_type |svtype type
Apa |OP* |newUNOP |I32 type|I32 flags|NULLOK OP* first
Apa |OP* |newWHENOP |NULLOK OP* cond|NN OP* block
Apa |OP* |newWHILEOP |I32 flags|I32 debuggable|NULLOK LOOP* loop \
diff --git a/embed.h b/embed.h
index 53186880bc..770c403769 100644
--- a/embed.h
+++ b/embed.h
@@ -583,6 +583,7 @@
#define vnewSVpvf Perl_vnewSVpvf
#define newSVrv Perl_newSVrv
#define newSVsv Perl_newSVsv
+#define newSV_type Perl_newSV_type
#define newUNOP Perl_newUNOP
#define newWHENOP Perl_newWHENOP
#define newWHILEOP Perl_newWHILEOP
@@ -2804,6 +2805,7 @@
#define vnewSVpvf(a,b) Perl_vnewSVpvf(aTHX_ a,b)
#define newSVrv(a,b) Perl_newSVrv(aTHX_ a,b)
#define newSVsv(a) Perl_newSVsv(aTHX_ a)
+#define newSV_type(a) Perl_newSV_type(aTHX_ a)
#define newUNOP(a,b,c) Perl_newUNOP(aTHX_ a,b,c)
#define newWHENOP(a,b) Perl_newWHENOP(aTHX_ a,b)
#define newWHILEOP(a,b,c,d,e,f,g,h) Perl_newWHILEOP(aTHX_ a,b,c,d,e,f,g,h)
diff --git a/global.sym b/global.sym
index 9ade2fa27e..6c8c8a012b 100644
--- a/global.sym
+++ b/global.sym
@@ -335,6 +335,7 @@ Perl_newSVpvf
Perl_vnewSVpvf
Perl_newSVrv
Perl_newSVsv
+Perl_newSV_type
Perl_newUNOP
Perl_newWHENOP
Perl_newWHILEOP
diff --git a/gv.c b/gv.c
index 475c225b22..3e428a7700 100644
--- a/gv.c
+++ b/gv.c
@@ -1354,9 +1354,7 @@ Perl_newIO(pTHX)
{
dVAR;
GV *iogv;
- IO * const io = (IO*)newSV(0);
-
- sv_upgrade((SV *)io,SVt_PVIO);
+ IO * const io = (IO*)newSV_type(SVt_PVIO);
/* This used to read SvREFCNT(io) = 1;
It's not clear why the reference count needed an explicit reset. NWC
*/
diff --git a/hv.c b/hv.c
index 903d0b80ea..98120fd037 100644
--- a/hv.c
+++ b/hv.c
@@ -1397,9 +1397,7 @@ HV *
Perl_newHV(pTHX)
{
register XPVHV* xhv;
- HV * const hv = (HV*)newSV(0);
-
- sv_upgrade((SV *)hv, SVt_PVHV);
+ HV * const hv = (HV*)newSV_type(SVt_PVHV);
xhv = (XPVHV*)SvANY(hv);
assert(!SvOK(hv));
#ifndef NODEFAULT_SHAREKEYS
@@ -2589,8 +2587,7 @@ S_refcounted_he_value(pTHX_ const struct refcounted_he *he)
case HVrhek_PV:
/* Create a string SV that directly points to the bytes in our
structure. */
- value = newSV(0);
- sv_upgrade(value, SVt_PV);
+ value = newSV_type(SVt_PV);
SvPV_set(value, (char *) he->refcounted_he_data + 1);
SvCUR_set(value, he->refcounted_he_val.refcounted_he_u_len);
/* This stops anything trying to free it */
diff --git a/mathoms.c b/mathoms.c
index 7d6f142c07..708645e30f 100644
--- a/mathoms.c
+++ b/mathoms.c
@@ -547,9 +547,7 @@ AV *
Perl_av_fake(pTHX_ register I32 size, register SV **strp)
{
register SV** ary;
- register AV * const av = (AV*)newSV(0);
-
- sv_upgrade((SV *)av, SVt_PVAV);
+ register AV * const av = (AV*)newSV_type(SVt_PVAV);
Newx(ary,size+1,SV*);
AvALLOC(av) = ary;
Copy(strp,ary,size,SV*);
diff --git a/op.c b/op.c
index 019184477e..ba25603414 100644
--- a/op.c
+++ b/op.c
@@ -5634,8 +5634,7 @@ Perl_newXS(pTHX_ const char *name, XSUBADDR_t subaddr, const char *filename)
if (cv) /* must reuse cv if autoloaded */
cv_undef(cv);
else {
- cv = (CV*)newSV(0);
- sv_upgrade((SV *)cv, SVt_PVCV);
+ cv = (CV*)newSV_type(SVt_PVCV);
if (name) {
GvCV(gv) = cv;
GvCVGEN(gv) = 0;
diff --git a/pad.c b/pad.c
index 415b59ebf9..f565ce2918 100644
--- a/pad.c
+++ b/pad.c
@@ -347,12 +347,11 @@ Perl_pad_add_name(pTHX_ const char *name, HV* typestash, HV* ourstash, bool fake
{
dVAR;
const PADOFFSET offset = pad_alloc(OP_PADSV, SVs_PADMY);
- SV* const namesv = newSV(0);
+ SV* const namesv
+ = newSV_type((ourstash || typestash) ? SVt_PVMG : SVt_PVNV);
ASSERT_CURPAD_ACTIVE("pad_add_name");
-
- sv_upgrade(namesv, (ourstash || typestash) ? SVt_PVMG : SVt_PVNV);
sv_setpv(namesv, name);
if (typestash) {
@@ -485,9 +484,8 @@ Perl_pad_add_anon(pTHX_ SV* sv, OPCODE op_type)
{
dVAR;
PADOFFSET ix;
- SV* const name = newSV(0);
+ SV* const name = newSV_type(SVt_PVNV);
pad_peg("add_anon");
- sv_upgrade(name, SVt_PVNV);
sv_setpvn(name, "&", 1);
/* Are these two actually ever read? */
COP_SEQ_RANGE_HIGH_set(name, ~0);
@@ -1457,8 +1455,7 @@ Perl_cv_clone(pTHX_ CV *proto)
ENTER;
SAVESPTR(PL_compcv);
- cv = PL_compcv = (CV*)newSV(0);
- sv_upgrade((SV *)cv, SvTYPE(proto));
+ cv = PL_compcv = (CV*)newSV_type(SvTYPE(proto));
CvFLAGS(cv) = CvFLAGS(proto) & ~(CVf_CLONE|CVf_WEAKOUTSIDE);
CvCLONED_on(cv);
diff --git a/perl.c b/perl.c
index 7a53b72e74..4dfea50763 100644
--- a/perl.c
+++ b/perl.c
@@ -2133,8 +2133,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
}
}
- PL_main_cv = PL_compcv = (CV*)newSV(0);
- sv_upgrade((SV *)PL_compcv, SVt_PVCV);
+ PL_main_cv = PL_compcv = (CV*)newSV_type(SVt_PVCV);
CvUNIQUE_on(PL_compcv);
CvPADLIST(PL_compcv) = pad_new(0);
@@ -4645,11 +4644,9 @@ S_init_postdump_symbols(pTHX_ register int argc, register char **argv, register
dVAR;
GV* tmpgv;
- PL_toptarget = newSV(0);
- sv_upgrade(PL_toptarget, SVt_PVFM);
+ PL_toptarget = newSV_type(SVt_PVFM);
sv_setpvn(PL_toptarget, "", 0);
- PL_bodytarget = newSV(0);
- sv_upgrade(PL_bodytarget, SVt_PVFM);
+ PL_bodytarget = newSV_type(SVt_PVFM);
sv_setpvn(PL_bodytarget, "", 0);
PL_formtarget = PL_bodytarget;
diff --git a/pp.c b/pp.c
index 04fab022d2..0cc80e67bb 100644
--- a/pp.c
+++ b/pp.c
@@ -323,8 +323,7 @@ PP(pp_av2arylen)
AV * const av = (AV*)TOPs;
SV ** const sv = Perl_av_arylen_p(aTHX_ (AV*)av);
if (!*sv) {
- *sv = newSV(0);
- sv_upgrade(*sv, SVt_PVMG);
+ *sv = newSV_type(SVt_PVMG);
sv_magic(*sv, (SV*)av, PERL_MAGIC_arylen, NULL, 0);
}
SETs(*sv);
diff --git a/pp_ctl.c b/pp_ctl.c
index ca19ebde9d..3aecb2dd9d 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2658,9 +2658,8 @@ S_save_lines(pTHX_ AV *array, SV *sv)
while (s && s < send) {
const char *t;
- SV * const tmpstr = newSV(0);
+ SV * const tmpstr = newSV_type(SVt_PVMG);
- sv_upgrade(tmpstr, SVt_PVMG);
t = strchr(s, '\n');
if (t)
t++;
@@ -2887,8 +2886,7 @@ S_doeval(pTHX_ int gimme, OP** startop, CV* outside, U32 seq)
PUSHMARK(SP);
SAVESPTR(PL_compcv);
- PL_compcv = (CV*)newSV(0);
- sv_upgrade((SV *)PL_compcv, SVt_PVCV);
+ PL_compcv = (CV*)newSV_type(SVt_PVCV);
CvEVAL_on(PL_compcv);
assert(CxTYPE(&cxstack[cxstack_ix]) == CXt_EVAL);
cxstack[cxstack_ix].blk_eval.cv = PL_compcv;
diff --git a/pp_hot.c b/pp_hot.c
index 5cd01be3ff..aa225c37da 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -1944,8 +1944,7 @@ PP(pp_iter)
if (lv)
SvREFCNT_dec(LvTARG(lv));
else {
- lv = cx->blk_loop.iterlval = newSV(0);
- sv_upgrade(lv, SVt_PVLV);
+ lv = cx->blk_loop.iterlval = newSV_type(SVt_PVLV);
LvTYPE(lv) = 'y';
sv_magic(lv, NULL, PERL_MAGIC_defelem, NULL, 0);
}
diff --git a/proto.h b/proto.h
index cd7bfe3d56..339ecca7d2 100644
--- a/proto.h
+++ b/proto.h
@@ -1642,6 +1642,10 @@ PERL_CALLCONV SV* Perl_newSVsv(pTHX_ SV* old)
__attribute__malloc__
__attribute__warn_unused_result__;
+PERL_CALLCONV SV* Perl_newSV_type(pTHX_ svtype type)
+ __attribute__malloc__
+ __attribute__warn_unused_result__;
+
PERL_CALLCONV OP* Perl_newUNOP(pTHX_ I32 type, I32 flags, OP* first)
__attribute__malloc__
__attribute__warn_unused_result__;
diff --git a/sv.c b/sv.c
index 38d7da7061..77627bda98 100644
--- a/sv.c
+++ b/sv.c
@@ -7168,6 +7168,25 @@ Perl_newSVuv(pTHX_ UV u)
}
/*
+=for apidoc newSV_type
+
+Creates a new SV, of the type specificied. The reference count for the new SV
+is set to 1.
+
+=cut
+*/
+
+SV *
+Perl_newSV_type(pTHX_ svtype type)
+{
+ register SV *sv;
+
+ new_SV(sv);
+ sv_upgrade(sv, type);
+ return sv;
+}
+
+/*
=for apidoc newRV_noinc
Creates an RV wrapper for an SV. The reference count for the original
@@ -7180,10 +7199,7 @@ SV *
Perl_newRV_noinc(pTHX_ SV *tmpRef)
{
dVAR;
- register SV *sv;
-
- new_SV(sv);
- sv_upgrade(sv, SVt_RV);
+ register SV *sv = newSV_type(SVt_RV);
SvTEMP_off(tmpRef);
SvRV_set(sv, tmpRef);
SvROK_on(sv);
diff --git a/toke.c b/toke.c
index 26f706ebed..7719aa537a 100644
--- a/toke.c
+++ b/toke.c
@@ -924,8 +924,7 @@ S_update_debugger_info(pTHX_ SV *orig_sv, const char *buf, STRLEN len)
{
AV *av = CopFILEAVx(PL_curcop);
if (av) {
- SV * const sv = newSV(0);
- sv_upgrade(sv, SVt_PVMG);
+ SV * const sv = newSV_type(SVt_PVMG);
if (orig_sv)
sv_setsv(sv, orig_sv);
else
@@ -12385,8 +12384,7 @@ Perl_start_subparse(pTHX_ I32 is_format, U32 flags)
save_item(PL_subname);
SAVESPTR(PL_compcv);
- PL_compcv = (CV*)newSV(0);
- sv_upgrade((SV *)PL_compcv, is_format ? SVt_PVFM : SVt_PVCV);
+ PL_compcv = (CV*)newSV_type(is_format ? SVt_PVFM : SVt_PVCV);
CvFLAGS(PL_compcv) |= flags;
PL_subline = CopLINE(PL_curcop);