summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Hay <SteveHay@planit.com>2006-01-18 14:23:09 +0000
committerSteve Hay <SteveHay@planit.com>2006-01-18 14:23:09 +0000
commit561b68a973f8a5d10c61d6a02c02f3002a0a63ba (patch)
tree84518a9894ce4759b487340358880b3081926f90
parent2f397494d2e5c4344bda444a704ca9e81d71a61b (diff)
downloadperl-561b68a973f8a5d10c61d6a02c02f3002a0a63ba.tar.gz
Change all NEWSV() to newSV() in the core and non-dual-lived modules.
Keep NEWSV() itself for backwards-compatibility outside of the core, but don't advertise it any more. (cf. change #25101). p4raw-link: @25101 on //depot/perl: a02a5408b2f199007c4dcb74559cc79066307ada p4raw-id: //depot/perl@26901
-rw-r--r--av.c10
-rw-r--r--doio.c2
-rw-r--r--dump.c4
-rw-r--r--ext/ByteLoader/bytecode.h2
-rw-r--r--ext/Opcode/Opcode.xs2
-rw-r--r--ext/POSIX/POSIX.xs2
-rw-r--r--gv.c8
-rw-r--r--handy.h12
-rw-r--r--hv.c8
-rw-r--r--mathoms.c2
-rw-r--r--op.c4
-rw-r--r--os2/OS2/REXX/REXX.xs2
-rw-r--r--pad.c16
-rw-r--r--perl.c24
-rw-r--r--perly.c6
-rw-r--r--pod/perlapi.pod23
-rw-r--r--pod/perlembed.pod8
-rw-r--r--pp.c10
-rw-r--r--pp_ctl.c10
-rw-r--r--pp_hot.c12
-rw-r--r--pp_pack.c6
-rw-r--r--pp_sys.c8
-rw-r--r--regexec.c3
-rw-r--r--scope.c8
-rw-r--r--sv.c21
-rw-r--r--toke.c32
-rw-r--r--vms/ext/Stdio/Stdio.xs2
27 files changed, 120 insertions, 127 deletions
diff --git a/av.c b/av.c
index 19aeffbd30..ede01a7b5b 100644
--- a/av.c
+++ b/av.c
@@ -239,13 +239,13 @@ Perl_av_fetch(pTHX_ register AV *av, I32 key, I32 lval)
if (key > AvFILLp(av)) {
if (!lval)
return 0;
- sv = NEWSV(5,0);
+ sv = newSV(0);
return av_store(av,key,sv);
}
if (AvARRAY(av)[key] == &PL_sv_undef) {
emptyness:
if (lval) {
- sv = NEWSV(6,0);
+ sv = newSV(0);
return av_store(av,key,sv);
}
return 0;
@@ -362,7 +362,7 @@ Creates a new AV. The reference count is set to 1.
AV *
Perl_newAV(pTHX)
{
- register AV * const av = (AV*)NEWSV(3,0);
+ register AV * const av = (AV*)newSV(0);
sv_upgrade((SV *)av, SVt_PVAV);
/* sv_upgrade does AvREAL_only() */
@@ -385,7 +385,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(8,0);
+ register AV * const av = (AV*)newSV(0);
sv_upgrade((SV *) av,SVt_PVAV);
/* sv_upgrade does AvREAL_only() */
@@ -399,7 +399,7 @@ Perl_av_make(pTHX_ register I32 size, register SV **strp)
AvMAX(av) = size - 1;
for (i = 0; i < size; i++) {
assert (*strp);
- ary[i] = NEWSV(7,0);
+ ary[i] = newSV(0);
sv_setsv(ary[i], *strp);
strp++;
}
diff --git a/doio.c b/doio.c
index 557c005daa..380e3c7150 100644
--- a/doio.c
+++ b/doio.c
@@ -2308,7 +2308,7 @@ PerlIO *
Perl_start_glob (pTHX_ SV *tmpglob, IO *io)
{
dVAR;
- SV * const tmpcmd = NEWSV(55, 0);
+ SV * const tmpcmd = newSV(0);
PerlIO *fp;
ENTER;
SAVEFREESV(tmpcmd);
diff --git a/dump.c b/dump.c
index 2930a58ff7..3b7fca4e7c 100644
--- a/dump.c
+++ b/dump.c
@@ -769,7 +769,7 @@ Perl_do_op_dump(pTHX_ I32 level, PerlIO *file, const OP *o)
#else
if ( ! PL_op->op_flags & OPf_SPECIAL) { /* not lexical */
if (cSVOPo->op_sv) {
- SV *tmpsv = NEWSV(0,0);
+ SV *tmpsv = newSV(0);
ENTER;
SAVEFREESV(tmpsv);
gv_fullname3(tmpsv, (GV*)cSVOPo->op_sv, Nullch);
@@ -1649,7 +1649,7 @@ Perl_debop(pTHX_ const OP *o)
case OP_GVSV:
case OP_GV:
if (cGVOPo_gv) {
- SV *sv = NEWSV(0,0);
+ SV *sv = newSV(0);
gv_fullname3(sv, cGVOPo_gv, Nullch);
PerlIO_printf(Perl_debug_log, "(%s)", SvPV_nolen_const(sv));
SvREFCNT_dec(sv);
diff --git a/ext/ByteLoader/bytecode.h b/ext/ByteLoader/bytecode.h
index b6bb12d036..7a6b485d18 100644
--- a/ext/ByteLoader/bytecode.h
+++ b/ext/ByteLoader/bytecode.h
@@ -190,7 +190,7 @@ typedef char *pvindex;
sv = (SV*)newHV(); \
break; \
default: \
- sv = NEWSV(0,0); \
+ sv = newSV(0); \
SvUPGRADE(sv, (arg)); \
}
#define BSET_newsvx(sv, arg) STMT_START { \
diff --git a/ext/Opcode/Opcode.xs b/ext/Opcode/Opcode.xs
index 8354b48845..86135e0d97 100644
--- a/ext/Opcode/Opcode.xs
+++ b/ext/Opcode/Opcode.xs
@@ -132,7 +132,7 @@ new_opset(pTHX_ SV *old_opset)
opset = newSVsv(old_opset);
}
else {
- opset = NEWSV(1156, opset_len);
+ opset = newSV(opset_len);
Zero(SvPVX_const(opset), opset_len + 1, char);
SvCUR_set(opset, opset_len);
(void)SvPOK_only(opset);
diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs
index 1edc62b4c4..730e7e0d8e 100644
--- a/ext/POSIX/POSIX.xs
+++ b/ext/POSIX/POSIX.xs
@@ -1679,7 +1679,7 @@ strxfrm(src)
STRLEN dstlen;
char *p = SvPV(src,srclen);
srclen++;
- ST(0) = sv_2mortal(NEWSV(800,srclen*4+1));
+ ST(0) = sv_2mortal(newSV(srclen*4+1));
dstlen = strxfrm(SvPVX(ST(0)), p, (size_t)srclen);
if (dstlen > srclen) {
dstlen++;
diff --git a/gv.c b/gv.c
index e669daf94d..f5f37944a3 100644
--- a/gv.c
+++ b/gv.c
@@ -45,7 +45,7 @@ Perl_gv_SVadd(pTHX_ GV *gv)
if (!gv || SvTYPE((SV*)gv) != SVt_PVGV)
Perl_croak(aTHX_ "Bad symbol for scalar");
if (!GvSV(gv))
- GvSV(gv) = NEWSV(72,0);
+ GvSV(gv) = newSV(0);
return gv;
}
#endif
@@ -196,7 +196,7 @@ Perl_gv_init(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len, int multi)
#ifdef PERL_DONT_CREATE_GVSV
GvSV(gv) = NULL;
#else
- GvSV(gv) = NEWSV(72,0);
+ GvSV(gv) = newSV(0);
#endif
GvLINE(gv) = CopLINE(PL_curcop);
/* XXX Ideally this cast would be replaced with a change to const char*
@@ -624,7 +624,7 @@ Perl_gv_autoload4(pTHX_ HV *stash, const char *name, STRLEN len, I32 method)
if (!isGV(vargv)) {
gv_init(vargv, varstash, S_autoload, S_autolen, FALSE);
#ifdef PERL_DONT_CREATE_GVSV
- GvSV(vargv) = NEWSV(72,0);
+ GvSV(vargv) = newSV(0);
#endif
}
LEAVE;
@@ -1244,7 +1244,7 @@ Perl_newIO(pTHX)
{
dVAR;
GV *iogv;
- IO * const io = (IO*)NEWSV(0,0);
+ IO * const io = (IO*)newSV(0);
sv_upgrade((SV *)io,SVt_PVIO);
/* This used to read SvREFCNT(io) = 1;
diff --git a/handy.h b/handy.h
index 3f13a93853..445611118b 100644
--- a/handy.h
+++ b/handy.h
@@ -554,15 +554,6 @@ typedef U32 line_t;
/*
-=head1 SV Manipulation Functions
-
-=for apidoc Am|SV*|NEWSV|int id|STRLEN len
-Creates a new SV. A non-zero C<len> parameter indicates the number of
-bytes of preallocated string space the SV should have. An extra byte for a
-tailing NUL is also reserved. (SvPOK is not set for the SV even if string
-space is allocated.) The reference count for the new SV is set to 1.
-C<id> is an integer id between 0 and 1299 (used to identify leaks).
-
=head1 Memory Management
=for apidoc Am|void|Newx|void* ptr|int nitems|type
@@ -631,7 +622,10 @@ hopefully catches attempts to access uninitialized memory.
=cut */
+/* Maintained for backwards-compatibility only. Use newSV() instead. */
+#ifndef PERL_CORE
#define NEWSV(x,len) newSV(len)
+#endif
#ifdef PERL_MALLOC_WRAP
#define MEM_WRAP_CHECK(n,t) MEM_WRAP_CHECK_1(n,t,PL_memory_wrap)
diff --git a/hv.c b/hv.c
index f12f117d99..c458f561ff 100644
--- a/hv.c
+++ b/hv.c
@@ -509,7 +509,7 @@ S_hv_fetch_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
call optimise. */
entry = hv_fetch_common(hv, keysv, key, klen,
flags, HV_FETCH_ISSTORE,
- NEWSV(61,0), hash);
+ newSV(0), hash);
} else {
if (flags & HVhek_FREEKEY)
Safefree(key);
@@ -729,7 +729,7 @@ S_hv_fetch_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
break;
}
/* LVAL fetch which actaully needs a store. */
- val = NEWSV(61,0);
+ val = newSV(0);
HvPLACEHOLDERS(hv)--;
} else {
/* store */
@@ -776,7 +776,7 @@ S_hv_fetch_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
return 0;
}
if (action & HV_FETCH_LVALUE) {
- val = NEWSV(61,0);
+ val = newSV(0);
if (SvMAGICAL(hv)) {
/* At this point the old hv_fetch code would call to hv_store,
which in turn might do some tied magic. So we need to make that
@@ -1398,7 +1398,7 @@ HV *
Perl_newHV(pTHX)
{
register XPVHV* xhv;
- HV * const hv = (HV*)NEWSV(502,0);
+ HV * const hv = (HV*)newSV(0);
sv_upgrade((SV *)hv, SVt_PVHV);
xhv = (XPVHV*)SvANY(hv);
diff --git a/mathoms.c b/mathoms.c
index 3a5ff3c1c1..d3713f56d5 100644
--- a/mathoms.c
+++ b/mathoms.c
@@ -510,7 +510,7 @@ AV *
Perl_av_fake(pTHX_ register I32 size, register SV **strp)
{
register SV** ary;
- register AV * const av = (AV*)NEWSV(9,0);
+ register AV * const av = (AV*)newSV(0);
sv_upgrade((SV *)av, SVt_PVAV);
Newx(ary,size+1,SV*);
diff --git a/op.c b/op.c
index 6ef7a50bc3..710d657d4e 100644
--- a/op.c
+++ b/op.c
@@ -4724,7 +4724,7 @@ Perl_newATTRSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block)
const char * const tname = (name ? name : aname);
if (PERLDB_SUBLINE && PL_curstash != PL_debstash) {
- SV * const sv = NEWSV(0,0);
+ SV * const sv = newSV(0);
SV * const tmpstr = sv_newmortal();
GV * const db_postponed = gv_fetchpv("DB::postponed", GV_ADDMULTI, SVt_PVHV);
HV *hv;
@@ -4908,7 +4908,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(1105,0);
+ cv = (CV*)newSV(0);
sv_upgrade((SV *)cv, SVt_PVCV);
if (name) {
GvCV(gv) = cv;
diff --git a/os2/OS2/REXX/REXX.xs b/os2/OS2/REXX/REXX.xs
index fb6ae2a9cf..2d1fa6ea21 100644
--- a/os2/OS2/REXX/REXX.xs
+++ b/os2/OS2/REXX/REXX.xs
@@ -138,7 +138,7 @@ exec_in_REXX_with(pTHX_ char *cmd, int c, char **handlerNames, RexxFunctionHandl
res = newSVpv(RXSTRPTR(result), RXSTRLEN(result));
DosFreeMem(RXSTRPTR(result));
} else {
- res = NEWSV(729,0);
+ res = newSV(0);
}
if (rc || SvTRUE(GvSV(PL_errgv))) {
if (SvTRUE(GvSV(PL_errgv))) {
diff --git a/pad.c b/pad.c
index 3ab7497301..4211b11f6c 100644
--- a/pad.c
+++ b/pad.c
@@ -333,7 +333,7 @@ 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(1102, 0);
+ SV* const namesv = newSV(0);
ASSERT_CURPAD_ACTIVE("pad_add_name");
@@ -469,7 +469,7 @@ Perl_pad_add_anon(pTHX_ SV* sv, OPCODE op_type)
{
dVAR;
PADOFFSET ix;
- SV* const name = NEWSV(1106, 0);
+ SV* const name = newSV(0);
sv_upgrade(name, SVt_PVNV);
sv_setpvn(name, "&", 1);
SvIV_set(name, -1);
@@ -1081,7 +1081,7 @@ Perl_pad_swipe(pTHX_ PADOFFSET po, bool refadjust)
/* if pad tmps aren't shared between ops, then there's no need to
* create a new tmp when an existing op is freed */
#ifdef USE_BROKEN_PAD_RESET
- PL_curpad[po] = NEWSV(1107,0);
+ PL_curpad[po] = newSV(0);
SvPADTMP_on(PL_curpad[po]);
#else
PL_curpad[po] = &PL_sv_undef;
@@ -1439,7 +1439,7 @@ Perl_cv_clone(pTHX_ CV *proto)
ENTER;
SAVESPTR(PL_compcv);
- cv = PL_compcv = (CV*)NEWSV(1104, 0);
+ cv = PL_compcv = (CV*)newSV(0);
sv_upgrade((SV *)cv, SvTYPE(proto));
CvFLAGS(cv) = CvFLAGS(proto) & ~(CVf_CLONE|CVf_WEAKOUTSIDE);
CvCLONED_on(cv);
@@ -1500,7 +1500,7 @@ Perl_cv_clone(pTHX_ CV *proto)
else if (sigil == '%')
sv = (SV*)newHV();
else
- sv = NEWSV(0, 0);
+ sv = newSV(0);
SvPADMY_on(sv);
}
}
@@ -1508,7 +1508,7 @@ Perl_cv_clone(pTHX_ CV *proto)
sv = SvREFCNT_inc(ppad[ix]);
}
else {
- sv = NEWSV(0, 0);
+ sv = newSV(0);
SvPADTMP_on(sv);
}
PL_curpad[ix] = sv;
@@ -1616,7 +1616,7 @@ Perl_pad_push(pTHX_ PADLIST *padlist, int depth)
else if (sigil == '%')
sv = (SV*)newHV();
else
- sv = NEWSV(0, 0);
+ sv = newSV(0);
av_store(newpad, ix, sv);
SvPADMY_on(sv);
}
@@ -1626,7 +1626,7 @@ Perl_pad_push(pTHX_ PADLIST *padlist, int depth)
}
else {
/* save temporaries on recursion? */
- SV * const sv = NEWSV(0, 0);
+ SV * const sv = newSV(0);
av_store(newpad, ix, sv);
SvPADTMP_on(sv);
}
diff --git a/perl.c b/perl.c
index 295859953c..dfd64bddca 100644
--- a/perl.c
+++ b/perl.c
@@ -242,7 +242,7 @@ perl_construct(pTHXx)
if (!PL_linestr) {
PL_curcop = &PL_compiling; /* needed by ckWARN, right away */
- PL_linestr = NEWSV(65,79);
+ PL_linestr = newSV(79);
sv_upgrade(PL_linestr,SVt_PVIV);
if (!SvREADONLY(&PL_sv_undef)) {
@@ -2067,7 +2067,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
}
- PL_main_cv = PL_compcv = (CV*)NEWSV(1104,0);
+ PL_main_cv = PL_compcv = (CV*)newSV(0);
sv_upgrade((SV *)PL_compcv, SVt_PVCV);
CvUNIQUE_on(PL_compcv);
@@ -3593,7 +3593,7 @@ S_open_script(pTHX_ const char *scriptname, bool dosearch, SV *sv)
else if (PL_preprocess) {
const char * const cpp_cfg = CPPSTDIN;
SV * const cpp = newSVpvs("");
- SV * const cmd = NEWSV(0,0);
+ SV * const cmd = newSV(0);
if (cpp_cfg[0] == 0) /* PERL_MICRO? */
Perl_croak(aTHX_ "Can't run with cpp -P with CPPSTDIN undefined");
@@ -4524,7 +4524,7 @@ S_init_predump_symbols(pTHX)
GvMULTI_on(tmpgv);
GvIOp(tmpgv) = (IO*)SvREFCNT_inc(io);
- PL_statname = NEWSV(66,0); /* last filename we did stat on */
+ PL_statname = newSV(0); /* last filename we did stat on */
Safefree(PL_osname);
PL_osname = savepv(OSNAME);
@@ -4576,10 +4576,10 @@ S_init_postdump_symbols(pTHX_ register int argc, register char **argv, register
dVAR;
GV* tmpgv;
- PL_toptarget = NEWSV(0,0);
+ PL_toptarget = newSV(0);
sv_upgrade(PL_toptarget, SVt_PVFM);
sv_setpvn(PL_toptarget, "", 0);
- PL_bodytarget = NEWSV(0,0);
+ PL_bodytarget = newSV(0);
sv_upgrade(PL_bodytarget, SVt_PVFM);
sv_setpvn(PL_bodytarget, "", 0);
PL_formtarget = PL_bodytarget;
@@ -4712,7 +4712,7 @@ S_init_perllib(pTHX)
#ifdef MACOS_TRADITIONAL
{
Stat_t tmpstatbuf;
- SV * privdir = NEWSV(55, 0);
+ SV * privdir = newSV(0);
char * macperl = PerlEnv_getenv("MACPERL");
if (!macperl)
@@ -4817,7 +4817,7 @@ S_incpush_if_exists(pTHX_ SV *dir)
if (PerlLIO_stat(SvPVX_const(dir), &tmpstatbuf) >= 0 &&
S_ISDIR(tmpstatbuf.st_mode)) {
av_push(GvAVn(PL_incgv), dir);
- dir = NEWSV(0,0);
+ dir = newSV(0);
}
return dir;
}
@@ -4834,12 +4834,12 @@ S_incpush(pTHX_ const char *dir, bool addsubdirs, bool addoldvers, bool usesep,
return;
if (addsubdirs || addoldvers) {
- subdir = NEWSV(0,0);
+ subdir = newSV(0);
}
/* Break at all separators */
while (p && *p) {
- SV *libdir = NEWSV(55,0);
+ SV *libdir = newSV(0);
const char *s;
/* skip any consecutive separators */
@@ -5097,10 +5097,10 @@ S_init_main_thread(pTHX)
* because sv_setpvn does SvTAINT and the taint
* fields thread selfness being set.
*/
- PL_toptarget = NEWSV(0,0);
+ PL_toptarget = newSV(0);
sv_upgrade(PL_toptarget, SVt_PVFM);
sv_setpvn(PL_toptarget, "", 0);
- PL_bodytarget = NEWSV(0,0);
+ PL_bodytarget = newSV(0);
sv_upgrade(PL_bodytarget, SVt_PVFM);
sv_setpvn(PL_bodytarget, "", 0);
PL_formtarget = PL_bodytarget;
diff --git a/perly.c b/perly.c
index 42efd9a0c4..c3f039b5d2 100644
--- a/perly.c
+++ b/perly.c
@@ -311,8 +311,8 @@ Perl_yyparse (pTHX)
PL_yycharp = &yychar; /* so PL_yyerror() can access it */
PL_yylvalp = &yylval; /* so various functions in toke.c can access it */
- yyss_sv = NEWSV(73, YYINITDEPTH * sizeof(short));
- yyvs_sv = NEWSV(73, YYINITDEPTH * sizeof(YYSTYPE));
+ yyss_sv = newSV(YYINITDEPTH * sizeof(short));
+ yyvs_sv = newSV(YYINITDEPTH * sizeof(YYSTYPE));
SAVEFREESV(yyss_sv);
SAVEFREESV(yyvs_sv);
yyss = (short *) SvPVX(yyss_sv);
@@ -321,7 +321,7 @@ Perl_yyparse (pTHX)
yyssp = yyss;
yyvsp = yyvs;
#ifdef DEBUGGING
- yyns_sv = NEWSV(73, YYINITDEPTH * sizeof(char *));
+ yyns_sv = newSV(YYINITDEPTH * sizeof(char *));
SAVEFREESV(yyns_sv);
/* XXX This seems strange to cast char * to char ** */
yyns = (const char **) SvPVX(yyns_sv);
diff --git a/pod/perlapi.pod b/pod/perlapi.pod
index 6e53740401..933b2aa99e 100644
--- a/pod/perlapi.pod
+++ b/pod/perlapi.pod
@@ -3474,26 +3474,19 @@ SV is B<not> incremented.
=for hackers
Found in file sv.c
-=item NEWSV
-X<NEWSV>
+=item newSV
+X<newSV>
Creates a new SV. A non-zero C<len> parameter indicates the number of
bytes of preallocated string space the SV should have. An extra byte for a
-tailing NUL is also reserved. (SvPOK is not set for the SV even if string
+trailing NUL is also reserved. (SvPOK is not set for the SV even if string
space is allocated.) The reference count for the new SV is set to 1.
-C<id> is an integer id between 0 and 1299 (used to identify leaks).
-
- SV* NEWSV(int id, STRLEN len)
-
-=for hackers
-Found in file handy.h
-
-=item newSV
-X<newSV>
-Create a new null SV, or if len > 0, create a new empty SVt_PV type SV
-with an initial PV allocation of len+1. Normally accessed via the C<NEWSV>
-macro.
+In 5.9.3, newSV() replaces the older NEWSV() API, and drops the first
+parameter, I<x>, a debug aid which allowed callers to identify themselves.
+This aid has been superseded by a new build option, PERL_MEM_LOG (see
+L<perlhack/PERL_MEM_LOG>). The older API is still there for use in XS
+modules supporting older perls.
SV* newSV(STRLEN len)
diff --git a/pod/perlembed.pod b/pod/perlembed.pod
index 0bd569fafb..9523e1f5ab 100644
--- a/pod/perlembed.pod
+++ b/pod/perlembed.pod
@@ -430,7 +430,7 @@ been wrapped here):
I32 match(SV *string, char *pattern)
{
- SV *command = NEWSV(1099, 0), *retval;
+ SV *command = newSV(0), *retval;
STRLEN n_a;
sv_setpvf(command, "my $string = '%s'; $string =~ %s",
@@ -452,7 +452,7 @@ been wrapped here):
I32 substitute(SV **string, char *pattern)
{
- SV *command = NEWSV(1099, 0), *retval;
+ SV *command = newSV(0), *retval;
STRLEN n_a;
sv_setpvf(command, "$string = '%s'; ($string =~ %s)",
@@ -475,7 +475,7 @@ been wrapped here):
I32 matches(SV *string, char *pattern, AV **match_list)
{
- SV *command = NEWSV(1099, 0);
+ SV *command = newSV(0);
I32 num_matches;
STRLEN n_a;
@@ -505,7 +505,7 @@ been wrapped here):
perl_parse(my_perl, NULL, 3, embedding, NULL);
PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
- text = NEWSV(1099,0);
+ text = newSV(0);
sv_setpv(text, "When he is at a convenience store and the "
"bill comes to some amount like 76 cents, Maynard is "
"aware that there is something he *should* do, something "
diff --git a/pp.c b/pp.c
index 304fced051..9676ce6501 100644
--- a/pp.c
+++ b/pp.c
@@ -163,7 +163,7 @@ PP(pp_rv2gv)
STRLEN len;
SV * const namesv = PAD_SV(cUNOP->op_targ);
const char * const name = SvPV(namesv, len);
- gv = (GV*)NEWSV(0,0);
+ gv = (GV*)newSV(0);
gv_init(gv, CopSTASH(PL_curcop), name, len, 0);
}
else {
@@ -298,7 +298,7 @@ PP(pp_av2arylen)
AV * const av = (AV*)TOPs;
SV ** const sv = Perl_av_arylen_p(aTHX_ (AV*)av);
if (!*sv) {
- *sv = NEWSV(0,0);
+ *sv = newSV(0);
sv_upgrade(*sv, SVt_PVMG);
sv_magic(*sv, (SV*)av, PERL_MAGIC_arylen, NULL, 0);
}
@@ -788,7 +788,7 @@ PP(pp_undef)
gp_free((GV*)sv);
Newxz(gp, 1, GP);
GvGP(sv) = gp_ref(gp);
- GvSV(sv) = NEWSV(72,0);
+ GvSV(sv) = newSV(0);
GvLINE(sv) = CopLINE(PL_curcop);
GvEGV(sv) = (GV*)sv;
GvMULTI_on(sv);
@@ -4003,7 +4003,7 @@ PP(pp_anonhash)
while (MARK < SP) {
SV * const key = *++MARK;
- SV * const val = NEWSV(46, 0);
+ SV * const val = newSV(0);
if (MARK < SP)
sv_setsv(val, *++MARK);
else if (ckWARN(WARN_MISC))
@@ -4241,7 +4241,7 @@ PP(pp_push)
}
else {
for (++MARK; MARK <= SP; MARK++) {
- SV * const sv = NEWSV(51, 0);
+ SV * const sv = newSV(0);
if (*MARK)
sv_setsv(sv, *MARK);
av_store(ary, AvFILLp(ary)+1, sv);
diff --git a/pp_ctl.c b/pp_ctl.c
index bdacfce917..4761deda33 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -1627,7 +1627,7 @@ PP(pp_caller)
GV * const cvgv = CvGV(ccstack[cxix].blk_sub.cv);
/* So is ccstack[dbcxix]. */
if (isGV(cvgv)) {
- SV * const sv = NEWSV(49, 0);
+ SV * const sv = newSV(0);
gv_efullname3(sv, cvgv, NULL);
PUSHs(sv_2mortal(sv));
PUSHs(sv_2mortal(newSViv((I32)cx->blk_sub.hasargs)));
@@ -1819,7 +1819,7 @@ PP(pp_enteriter)
GV * const gv = (GV*)POPs;
svp = &GvSV(gv); /* symbol table variable */
SAVEGENERICSV(*svp);
- *svp = NEWSV(0,0);
+ *svp = newSV(0);
#ifdef USE_ITHREADS
iterdata = (void*)gv;
#endif
@@ -2659,7 +2659,7 @@ S_save_lines(pTHX_ AV *array, SV *sv)
while (s && s < send) {
const char *t;
- SV * const tmpstr = NEWSV(85,0);
+ SV * const tmpstr = newSV(0);
sv_upgrade(tmpstr, SVt_PVMG);
t = strchr(s, '\n');
@@ -2889,7 +2889,7 @@ S_doeval(pTHX_ int gimme, OP** startop, CV* outside, U32 seq)
PUSHMARK(SP);
SAVESPTR(PL_compcv);
- PL_compcv = (CV*)NEWSV(1104,0);
+ PL_compcv = (CV*)newSV(0);
sv_upgrade((SV *)PL_compcv, SVt_PVCV);
CvEVAL_on(PL_compcv);
assert(CxTYPE(&cxstack[cxstack_ix]) == CXt_EVAL);
@@ -3144,7 +3144,7 @@ PP(pp_require)
if ((unixname = tounixspec(name, NULL)) != NULL)
#endif
{
- namesv = NEWSV(806, 0);
+ namesv = newSV(0);
for (i = 0; i <= AvFILL(ar); i++) {
SV *dirsv = *av_fetch(ar, i, TRUE);
diff --git a/pp_hot.c b/pp_hot.c
index 38ad000c36..babcb5e115 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -1017,7 +1017,7 @@ S_do_oddball(pTHX_ HV *hash, SV **relem, SV **firstrelem)
Perl_warner(aTHX_ packWARN(WARN_MISC), err);
}
- tmpstr = NEWSV(29,0);
+ tmpstr = newSV(0);
didstore = hv_store_ent(hash,*relem,tmpstr,0);
if (SvMAGICAL(hash)) {
if (SvSMAGICAL(tmpstr))
@@ -1110,7 +1110,7 @@ PP(pp_aassign)
HE *didstore;
sv = *relem ? *relem : &PL_sv_no;
relem++;
- tmpstr = NEWSV(29,0);
+ tmpstr = newSV(0);
if (*relem)
sv_setsv(tmpstr,*relem); /* value */
*(relem++) = tmpstr;
@@ -1624,7 +1624,7 @@ Perl_do_readline(pTHX)
}
}
else {
- sv = sv_2mortal(NEWSV(57, 80));
+ sv = sv_2mortal(newSV(80));
offset = 0;
}
@@ -1713,7 +1713,7 @@ Perl_do_readline(pTHX)
if (SvLEN(sv) - SvCUR(sv) > 20) {
SvPV_shrink_to_cur(sv);
}
- sv = sv_2mortal(NEWSV(58, 80));
+ sv = sv_2mortal(newSV(80));
continue;
}
else if (gimme == G_SCALAR && !tmplen && SvLEN(sv) - SvCUR(sv) > 80) {
@@ -1999,7 +1999,7 @@ PP(pp_iter)
if (lv)
SvREFCNT_dec(LvTARG(lv));
else {
- lv = cx->blk_loop.iterlval = NEWSV(26, 0);
+ lv = cx->blk_loop.iterlval = newSV(0);
sv_upgrade(lv, SVt_PVLV);
LvTYPE(lv) = 'y';
sv_magic(lv, NULL, PERL_MAGIC_defelem, NULL, 0);
@@ -3006,7 +3006,7 @@ Perl_vivify_ref(pTHX_ SV *sv, U32 to_what)
}
switch (to_what) {
case OPpDEREF_SV:
- SvRV_set(sv, NEWSV(355,0));
+ SvRV_set(sv, newSV(0));
break;
case OPpDEREF_AV:
SvRV_set(sv, (SV*)newAV());
diff --git a/pp_pack.c b/pp_pack.c
index 72f8c0e714..3518298046 100644
--- a/pp_pack.c
+++ b/pp_pack.c
@@ -1537,7 +1537,7 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c
break;
}
- sv = sv_2mortal(NEWSV(35, len ? len : 1));
+ sv = sv_2mortal(newSV(len ? len : 1));
SvPOK_on(sv);
str = SvPVX(sv);
if (datumtype == 'b') {
@@ -1574,7 +1574,7 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c
/* Preliminary length estimate, acceptable for utf8 too */
if (howlen == e_star || len > (strend - s) * 2)
len = (strend - s) * 2;
- sv = sv_2mortal(NEWSV(35, len ? len : 1));
+ sv = sv_2mortal(newSV(len ? len : 1));
SvPOK_on(sv);
str = SvPVX(sv);
if (datumtype == 'h') {
@@ -2143,7 +2143,7 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c
}
{
const STRLEN l = (STRLEN) (strend - s) * 3 / 4;
- sv = sv_2mortal(NEWSV(42, l));
+ sv = sv_2mortal(newSV(l));
if (l) SvPOK_on(sv);
}
if (utf8) {
diff --git a/pp_sys.c b/pp_sys.c
index 9777f695a1..d3b347d420 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -352,7 +352,7 @@ PP(pp_backtick)
}
else {
for (;;) {
- SV * const sv = NEWSV(56, 79);
+ SV * const sv = newSV(79);
if (sv_gets(sv, fp, 0) == Nullch) {
SvREFCNT_dec(sv);
break;
@@ -1460,7 +1460,7 @@ PP(pp_prtf)
RETURN;
}
- sv = NEWSV(0,0);
+ sv = newSV(0);
if (!(io = GvIO(gv))) {
if (ckWARN2(WARN_UNOPENED,WARN_CLOSED))
report_evil_fh(gv, io, PL_op->op_type);
@@ -2567,7 +2567,7 @@ PP(pp_ssockopt)
#ifdef HAS_SOCKET
dVAR; dSP;
const int optype = PL_op->op_type;
- SV * const sv = (optype == OP_GSOCKOPT) ? sv_2mortal(NEWSV(22, 257)) : POPs;
+ SV * const sv = (optype == OP_GSOCKOPT) ? sv_2mortal(newSV(257)) : POPs;
const unsigned int optname = (unsigned int) POPi;
const unsigned int lvl = (unsigned int) POPi;
GV * const gv = (GV*)POPs;
@@ -2653,7 +2653,7 @@ PP(pp_getpeername)
if (!io || !IoIFP(io))
goto nuts;
- sv = sv_2mortal(NEWSV(22, 257));
+ sv = sv_2mortal(newSV(257));
(void)SvPOK_only(sv);
len = 256;
SvCUR_set(sv, len);
diff --git a/regexec.c b/regexec.c
index 7ca466737c..fa13a58d8a 100644
--- a/regexec.c
+++ b/regexec.c
@@ -2315,8 +2315,7 @@ typedef union re_unwind_t {
ENTER; \
SAVETMPS; \
bufflen = TRIE_INITAL_ACCEPT_BUFFLEN ; \
- sv_accept_buff=NEWSV( 1234, \
- bufflen * sizeof(reg_trie_accepted) - 1 ); \
+ sv_accept_buff=newSV(bufflen * sizeof(reg_trie_accepted) - 1 );\
SvCUR_set( sv_accept_buff, sizeof(reg_trie_accepted) ); \
SvPOK_on( sv_accept_buff ); \
sv_2mortal( sv_accept_buff ); \
diff --git a/scope.c b/scope.c
index 0b44fba372..d0be78afe3 100644
--- a/scope.c
+++ b/scope.c
@@ -163,7 +163,7 @@ S_save_scalar_at(pTHX_ SV **sptr)
{
dVAR;
SV * const osv = *sptr;
- register SV * const sv = *sptr = NEWSV(0,0);
+ register SV * const sv = *sptr = newSV(0);
if (SvTYPE(osv) >= SVt_PVMG && SvMAGIC(osv) && SvTYPE(osv) != SVt_PVGV) {
if (SvGMAGICAL(osv)) {
@@ -281,7 +281,7 @@ Perl_save_gp(pTHX_ GV *gv, I32 empty)
IoFLAGS(gp->gp_io) |= IOf_ARGV|IOf_START;
}
GvGP(gv) = gp_ref(gp);
- GvSV(gv) = NEWSV(72,0);
+ GvSV(gv) = newSV(0);
GvLINE(gv) = CopLINE(PL_curcop);
/* XXX Ideally this cast would be replaced with a change to const char*
in the struct. */
@@ -563,7 +563,7 @@ Perl_save_list(pTHX_ register SV **sarg, I32 maxsarg)
register I32 i;
for (i = 1; i <= maxsarg; i++) {
- register SV * const sv = NEWSV(0,0);
+ register SV * const sv = newSV(0);
sv_setsv(sv,sarg[i]);
SSCHECK(3);
SSPUSHPTR(sarg[i]); /* remember the pointer */
@@ -909,7 +909,7 @@ Perl_leave_scope(pTHX_ I32 base)
switch (SvTYPE(sv)) { /* Console ourselves with a new value */
case SVt_PVAV: *(SV**)ptr = (SV*)newAV(); break;
case SVt_PVHV: *(SV**)ptr = (SV*)newHV(); break;
- default: *(SV**)ptr = NEWSV(0,0); break;
+ default: *(SV**)ptr = newSV(0); break;
}
SvREFCNT_dec(sv); /* Cast current value to the winds. */
/* preserve pad nature, but also mark as not live
diff --git a/sv.c b/sv.c
index 72412f7999..6c884b04f9 100644
--- a/sv.c
+++ b/sv.c
@@ -4013,9 +4013,16 @@ Perl_sv_catpv_mg(pTHX_ register SV *sv, register const char *ptr)
/*
=for apidoc newSV
-Create a new null SV, or if len > 0, create a new empty SVt_PV type SV
-with an initial PV allocation of len+1. Normally accessed via the C<NEWSV>
-macro.
+Creates a new SV. A non-zero C<len> parameter indicates the number of
+bytes of preallocated string space the SV should have. An extra byte for a
+trailing NUL is also reserved. (SvPOK is not set for the SV even if string
+space is allocated.) The reference count for the new SV is set to 1.
+
+In 5.9.3, newSV() replaces the older NEWSV() API, and drops the first
+parameter, I<x>, a debug aid which allowed callers to identify themselves.
+This aid has been superseded by a new build option, PERL_MEM_LOG (see
+L<perlhack/PERL_MEM_LOG>). The older API is still there for use in XS
+modules supporting older perls.
=cut
*/
@@ -5761,7 +5768,7 @@ Perl_sv_gets(pTHX_ register SV *sv, register PerlIO *fp, I32 append)
sv_pos_u2b(sv,&append,0);
}
} else if (SvUTF8(sv)) {
- SV * const tsv = NEWSV(0,0);
+ SV * const tsv = newSV(0);
sv_gets(tsv, fp, 0);
sv_utf8_upgrade_nomg(tsv);
SvCUR_set(sv,append);
@@ -6951,7 +6958,7 @@ Perl_sv_2cv(pTHX_ SV *sv, HV **st, GV **gvp, I32 lref)
if (lref && !GvCVu(gv)) {
SV *tmpsv;
ENTER;
- tmpsv = NEWSV(704,0);
+ tmpsv = newSV(0);
gv_efullname3(tmpsv, gv, Nullch);
/* XXX this is probably not what they think they're getting.
* It has the same effect as "sub name;", i.e. just a forward
@@ -10644,7 +10651,7 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags,
PL_linestart = SvPVX(PL_linestr) + (i < 0 ? 0 : i);
}
else {
- PL_linestr = NEWSV(65,79);
+ PL_linestr = newSV(79);
sv_upgrade(PL_linestr,SVt_PVIV);
sv_setpvn(PL_linestr,"",0);
PL_bufptr = PL_oldbufptr = PL_oldoldbufptr = PL_linestart = SvPVX(PL_linestr);
@@ -11239,7 +11246,7 @@ S_varname(pTHX_ GV *gv, const char gvtype, PADOFFSET targ,
}
if (subscript_type == FUV_SUBSCRIPT_HASH) {
- SV * const sv = NEWSV(0,0);
+ SV * const sv = newSV(0);
*SvPVX(name) = '$';
Perl_sv_catpvf(aTHX_ name, "{%s}",
pv_display(sv,SvPVX_const(keyname), SvCUR(keyname), 0, 32));
diff --git a/toke.c b/toke.c
index 6f27031874..12f7ace57e 100644
--- a/toke.c
+++ b/toke.c
@@ -844,7 +844,7 @@ S_skipspace(pTHX_ register char *s)
* so store the line into the debugger's array of lines
*/
if (PERLDB_LINE && PL_curstash != PL_debstash) {
- SV * const sv = NEWSV(85,0);
+ SV * const sv = newSV(0);
sv_upgrade(sv, SVt_PVMG);
sv_setpvn(sv,PL_bufptr,PL_bufend-PL_bufptr);
@@ -1439,7 +1439,7 @@ S_scan_const(pTHX_ char *start)
{
dVAR;
register char *send = PL_bufend; /* end of the constant */
- SV *sv = NEWSV(93, send - start); /* sv for the constant */
+ SV *sv = newSV(send - start); /* sv for the constant */
register char *s = start; /* start of the constant */
register char *d = SvPVX(sv); /* destination for copies */
bool dorange = FALSE; /* are we in a translit range? */
@@ -2237,7 +2237,7 @@ Perl_filter_add(pTHX_ filter_t funcp, SV *datasv)
if (!PL_rsfp_filters)
PL_rsfp_filters = newAV();
if (!datasv)
- datasv = NEWSV(255,0);
+ datasv = newSV(0);
SvUPGRADE(datasv, SVt_PVIO);
IoANY(datasv) = FPTR2DPTR(void *, funcp); /* stash funcp into spare field */
IoFLAGS(datasv) |= IOf_FAKE_DIRP;
@@ -2753,7 +2753,7 @@ Perl_yylex(pTHX)
PL_bufend = SvPVX(PL_linestr) + SvCUR(PL_linestr);
PL_last_lop = PL_last_uni = Nullch;
if (PERLDB_LINE && PL_curstash != PL_debstash) {
- SV * const sv = NEWSV(85,0);
+ SV * const sv = newSV(0);
sv_upgrade(sv, SVt_PVMG);
sv_setsv(sv,PL_linestr);
@@ -2840,7 +2840,7 @@ Perl_yylex(pTHX)
} while (PL_doextract);
PL_oldoldbufptr = PL_oldbufptr = PL_bufptr = PL_linestart = s;
if (PERLDB_LINE && PL_curstash != PL_debstash) {
- SV * const sv = NEWSV(85,0);
+ SV * const sv = newSV(0);
sv_upgrade(sv, SVt_PVMG);
sv_setsv(sv,PL_linestr);
@@ -9800,7 +9800,7 @@ S_scan_heredoc(pTHX_ register char *s)
}
s += SvCUR(herewas);
- tmpstr = NEWSV(87,79);
+ tmpstr = newSV(79);
sv_upgrade(tmpstr, SVt_PVIV);
if (term == '\'') {
op_type = OP_CONST;
@@ -9889,7 +9889,7 @@ S_scan_heredoc(pTHX_ register char *s)
PL_bufend[-1] = '\n';
#endif
if (PERLDB_LINE && PL_curstash != PL_debstash) {
- SV * const sv = NEWSV(88,0);
+ SV * const sv = newSV(0);
sv_upgrade(sv, SVt_PVMG);
sv_setsv(sv,PL_linestr);
@@ -10178,9 +10178,9 @@ S_scan_str(pTHX_ char *start, int keep_quoted, int keep_delims)
PL_multi_close = term;
- /* create a new SV to hold the contents. 87 is leak category, I'm
- assuming. 79 is the SV's initial length. What a random number. */
- sv = NEWSV(87,79);
+ /* create a new SV to hold the contents. 79 is the SV's initial length.
+ What a random number. */
+ sv = newSV(79);
sv_upgrade(sv, SVt_PVIV);
SvIV_set(sv, termcode);
(void)SvPOK_only(sv); /* validate pointer */
@@ -10364,7 +10364,7 @@ S_scan_str(pTHX_ char *start, int keep_quoted, int keep_delims)
/* update debugger info */
if (PERLDB_LINE && PL_curstash != PL_debstash) {
- SV * const sv = NEWSV(88,0);
+ SV * const sv = newSV(0);
sv_upgrade(sv, SVt_PVMG);
sv_setsv(sv,PL_linestr);
@@ -10602,7 +10602,7 @@ Perl_scan_num(pTHX_ const char *start, YYSTYPE* lvalp)
Perl_warner(aTHX_ packWARN(WARN_SYNTAX), "Misplaced _ in number");
}
- sv = NEWSV(92,0);
+ sv = newSV(0);
if (overflowed) {
if (n > 4294967295.0 && ckWARN(WARN_PORTABLE))
Perl_warner(aTHX_ packWARN(WARN_PORTABLE),
@@ -10755,7 +10755,7 @@ Perl_scan_num(pTHX_ const char *start, YYSTYPE* lvalp)
/* make an sv from the string */
- sv = NEWSV(92,0);
+ sv = newSV(0);
/*
We try to do an integer conversion first if no characters
@@ -10796,7 +10796,7 @@ Perl_scan_num(pTHX_ const char *start, YYSTYPE* lvalp)
/* if it starts with a v, it could be a v-string */
case 'v':
vstring:
- sv = NEWSV(92,5); /* preallocate storage space */
+ sv = newSV(5); /* preallocate storage space */
s = scan_vstring(s,sv);
break;
}
@@ -10930,7 +10930,7 @@ Perl_start_subparse(pTHX_ I32 is_format, U32 flags)
save_item(PL_subname);
SAVESPTR(PL_compcv);
- PL_compcv = (CV*)NEWSV(1104,0);
+ PL_compcv = (CV*)newSV(0);
sv_upgrade((SV *)PL_compcv, is_format ? SVt_PVFM : SVt_PVCV);
CvFLAGS(PL_compcv) |= flags;
@@ -11218,7 +11218,7 @@ vstring, as well as updating the passed in sv.
Function must be called like
- sv = NEWSV(92,5);
+ sv = newSV(5);
s = scan_vstring(s,sv);
The sv should already be large enough to store the vstring
diff --git a/vms/ext/Stdio/Stdio.xs b/vms/ext/Stdio/Stdio.xs
index d7259234ee..3843641065 100644
--- a/vms/ext/Stdio/Stdio.xs
+++ b/vms/ext/Stdio/Stdio.xs
@@ -83,7 +83,7 @@ IV *pval;
static SV *
newFH(PerlIO *fp, char type) {
SV *rv;
- GV **stashp, *gv = (GV *)NEWSV(0,0);
+ GV **stashp, *gv = (GV *)newSV(0);
HV *stash;
IO *io;