Skip to content

Commit

Permalink
Change all NEWSV() to newSV() in the core and non-dual-lived modules.
Browse files Browse the repository at this point in the history
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: a02a540

p4raw-id: //depot/perl@26901
  • Loading branch information
Steve Hay authored and Steve Hay committed Jan 18, 2006
1 parent 2f39749 commit 561b68a
Show file tree
Hide file tree
Showing 27 changed files with 120 additions and 127 deletions.
10 changes: 5 additions & 5 deletions av.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() */
Expand All @@ -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() */
Expand All @@ -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++;
}
Expand Down
2 changes: 1 addition & 1 deletion doio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion ext/ByteLoader/bytecode.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 { \
Expand Down
2 changes: 1 addition & 1 deletion ext/Opcode/Opcode.xs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion ext/POSIX/POSIX.xs
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down
8 changes: 4 additions & 4 deletions gv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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*
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 3 additions & 9 deletions handy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions hv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion mathoms.c
Original file line number Diff line number Diff line change
Expand Up @@ -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*);
Expand Down
4 changes: 2 additions & 2 deletions op.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion os2/OS2/REXX/REXX.xs
Original file line number Diff line number Diff line change
Expand Up @@ -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))) {
Expand Down
16 changes: 8 additions & 8 deletions pad.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1500,15 +1500,15 @@ Perl_cv_clone(pTHX_ CV *proto)
else if (sigil == '%')
sv = (SV*)newHV();
else
sv = NEWSV(0, 0);
sv = newSV(0);
SvPADMY_on(sv);
}
}
else if (IS_PADGV(ppad[ix]) || IS_PADCONST(ppad[ix])) {
sv = SvREFCNT_inc(ppad[ix]);
}
else {
sv = NEWSV(0, 0);
sv = newSV(0);
SvPADTMP_on(sv);
}
PL_curpad[ix] = sv;
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down
24 changes: 12 additions & 12 deletions perl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
Expand All @@ -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 */
Expand Down Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 561b68a

Please sign in to comment.