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;
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() */
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() */
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++;
}
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);
#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);
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);
sv = (SV*)newHV(); \
break; \
default: \
- sv = NEWSV(0,0); \
+ sv = newSV(0); \
SvUPGRADE(sv, (arg)); \
}
#define BSET_newsvx(sv, arg) STMT_START { \
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);
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++;
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
#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*
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;
{
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;
/*
-=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
=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)
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);
break;
}
/* LVAL fetch which actaully needs a store. */
- val = NEWSV(61,0);
+ val = newSV(0);
HvPLACEHOLDERS(hv)--;
} else {
/* store */
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
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);
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*);
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;
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;
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))) {
{
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");
{
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);
/* 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;
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);
else if (sigil == '%')
sv = (SV*)newHV();
else
- sv = NEWSV(0, 0);
+ sv = newSV(0);
SvPADMY_on(sv);
}
}
sv = SvREFCNT_inc(ppad[ix]);
}
else {
- sv = NEWSV(0, 0);
+ sv = newSV(0);
SvPADTMP_on(sv);
}
PL_curpad[ix] = sv;
else if (sigil == '%')
sv = (SV*)newHV();
else
- sv = NEWSV(0, 0);
+ sv = newSV(0);
av_store(newpad, ix, sv);
SvPADMY_on(sv);
}
}
else {
/* save temporaries on recursion? */
- SV * const sv = NEWSV(0, 0);
+ SV * const sv = newSV(0);
av_store(newpad, ix, sv);
SvPADTMP_on(sv);
}
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)) {
}
- 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);
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");
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);
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;
#ifdef MACOS_TRADITIONAL
{
Stat_t tmpstatbuf;
- SV * privdir = NEWSV(55, 0);
+ SV * privdir = newSV(0);
char * macperl = PerlEnv_getenv("MACPERL");
if (!macperl)
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;
}
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 */
* 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;
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);
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);
=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)
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",
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)",
I32 matches(SV *string, char *pattern, AV **match_list)
{
- SV *command = NEWSV(1099, 0);
+ SV *command = newSV(0);
I32 num_matches;
STRLEN n_a;
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 "
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 {
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);
}
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);
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))
}
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);
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)));
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
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');
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);
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);
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))
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;
}
}
else {
- sv = sv_2mortal(NEWSV(57, 80));
+ sv = sv_2mortal(newSV(80));
offset = 0;
}
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) {
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);
}
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());
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') {
/* 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') {
}
{
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) {
}
else {
for (;;) {
- SV * const sv = NEWSV(56, 79);
+ SV * const sv = newSV(79);
if (sv_gets(sv, fp, 0) == Nullch) {
SvREFCNT_dec(sv);
break;
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);
#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;
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);
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 ); \
{
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)) {
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. */
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 */
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
/*
=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
*/
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);
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
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);
}
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));
* 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);
{
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? */
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;
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);
} 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);
}
s += SvCUR(herewas);
- tmpstr = NEWSV(87,79);
+ tmpstr = newSV(79);
sv_upgrade(tmpstr, SVt_PVIV);
if (term == '\'') {
op_type = OP_CONST;
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);
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 */
/* 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);
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),
/* make an sv from the string */
- sv = NEWSV(92,0);
+ sv = newSV(0);
/*
We try to do an integer conversion first if no characters
/* 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;
}
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;
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
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;