From: Nicholas Clark Date: Thu, 15 Oct 2009 22:17:02 +0000 (+0100) Subject: Replace sv_2mortal(newSVpvn(...)) with newSVpvn_flags(..., SVs_TEMP) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d3d348849d1e04f91e458937b2aba39c00de63af;p=p5sagit%2Fp5-mst-13.2.git Replace sv_2mortal(newSVpvn(...)) with newSVpvn_flags(..., SVs_TEMP) --- diff --git a/ext/B/B.xs b/ext/B/B.xs index 1d32c04..2b6fb8d 100644 --- a/ext/B/B.xs +++ b/ext/B/B.xs @@ -792,7 +792,7 @@ hash(sv) const char *s = SvPV(sv, len); PERL_HASH(hash, s, len); len = my_sprintf(hexhash, "0x%"UVxf, (UV)hash); - ST(0) = sv_2mortal(newSVpvn(hexhash, len)); + ST(0) = newSVpvn_flags(hexhash, len, SVs_TEMP); #define cast_I32(foo) (I32)foo IV @@ -843,7 +843,7 @@ threadsv_names() EXTEND(sp, len); for (i = 0; i < len; i++) - PUSHs(sv_2mortal(newSVpvn(&PL_threadsv_names[i], 1))); + PUSHs(newSVpvn_flags(&PL_threadsv_names[i], 1, SVs_TEMP)); # endif #endif @@ -1168,13 +1168,13 @@ PVOP_pv(o) { const short* const tbl = (short*)o->op_pv; const short entries = 257 + tbl[256]; - ST(0) = sv_2mortal(newSVpvn(o->op_pv, entries * sizeof(short))); + ST(0) = newSVpvn_flags(o->op_pv, entries * sizeof(short), SVs_TEMP); } else if (o->op_type == OP_TRANS) { - ST(0) = sv_2mortal(newSVpvn(o->op_pv, 256 * sizeof(short))); + ST(0) = newSVpvn_flags(o->op_pv, 256 * sizeof(short), SVs_TEMP); } else - ST(0) = sv_2mortal(newSVpv(o->op_pv, 0)); + ST(0) = newSVpvn_flags(o->op_pv, strlen(o->op_pv), SVs_TEMP); #define LOOP_redoop(o) o->op_redoop #define LOOP_nextop(o) o->op_nextop @@ -1372,10 +1372,10 @@ packiv(sv) wp[0] = htonl(((U32)iv) >> (sizeof(UV)*4)); #endif wp[1] = htonl(iv & 0xffffffff); - ST(0) = sv_2mortal(newSVpvn((char *)wp, 8)); + ST(0) = newSVpvn_flags((char *)wp, 8, SVs_TEMP); } else { U32 w = htonl((U32)SvIVX(sv)); - ST(0) = sv_2mortal(newSVpvn((char *)&w, 4)); + ST(0) = newSVpvn_flags((char *)&w, 4, SVs_TEMP); } @@ -1659,7 +1659,7 @@ BmTABLE(sv) CODE: str = SvPV(sv, len); /* Boyer-Moore table is just after string and its safety-margin \0 */ - ST(0) = sv_2mortal(newSVpvn(str + len + PERL_FBM_TABLE_OFFSET, 256)); + ST(0) = newSVpvn_flags(str + len + PERL_FBM_TABLE_OFFSET, 256, SVs_TEMP); MODULE = B PACKAGE = B::GV PREFIX = Gv @@ -1670,7 +1670,7 @@ GvNAME(gv) #if PERL_VERSION >= 10 ST(0) = sv_2mortal(newSVhek(GvNAME_HEK(gv))); #else - ST(0) = sv_2mortal(newSVpvn(GvNAME(gv), GvNAMELEN(gv))); + ST(0) = newSVpvn_flags(GvNAME(gv), GvNAMELEN(gv), SVs_TEMP); #endif bool diff --git a/ext/File-Glob/Glob.pm b/ext/File-Glob/Glob.pm index 15d4adb..7c6b92c 100644 --- a/ext/File-Glob/Glob.pm +++ b/ext/File-Glob/Glob.pm @@ -56,7 +56,7 @@ use XSLoader (); ) ], ); -$VERSION = '1.06'; +$VERSION = '1.07'; sub import { require Exporter; diff --git a/ext/File-Glob/Glob.xs b/ext/File-Glob/Glob.xs index 3a526fb..59345e7 100644 --- a/ext/File-Glob/Glob.xs +++ b/ext/File-Glob/Glob.xs @@ -59,8 +59,8 @@ PPCODE: EXTEND(sp, pglob.gl_pathc); for (i = 0; i < pglob.gl_pathc; i++) { /* printf("# bsd_glob: %s\n", pglob.gl_pathv[i]); */ - tmp = sv_2mortal(newSVpvn(pglob.gl_pathv[i], - strlen(pglob.gl_pathv[i]))); + tmp = newSVpvn_flags(pglob.gl_pathv[i], strlen(pglob.gl_pathv[i]), + SVs_TEMP); TAINT; SvTAINT(tmp); PUSHs(tmp); diff --git a/ext/Opcode/Opcode.xs b/ext/Opcode/Opcode.xs index 5f2979c..e1af6d5 100644 --- a/ext/Opcode/Opcode.xs +++ b/ext/Opcode/Opcode.xs @@ -371,7 +371,8 @@ PPCODE: const U16 bits = bitmap[i]; for (j=0; j < 8 && myopcode < PL_maxo; j++, myopcode++) { if ( bits & (1 << j) ) - XPUSHs(sv_2mortal(newSVpv(names[myopcode], 0))); + XPUSHs(newSVpvn_flags(names[myopcode], strlen(names[myopcode]), + SVs_TEMP)); } } } @@ -458,7 +459,7 @@ PPCODE: /* copy args to a scratch area since we may push output values onto */ /* the stack faster than we read values off it if masks are used. */ - args = (SV**)SvPVX(sv_2mortal(newSVpvn((char*)&ST(0), items*sizeof(SV*)))); + args = (SV**)SvPVX(newSVpvn_flags((char*)&ST(0), items*sizeof(SV*), SVs_TEMP)); for (i = 0; i < items; i++) { const char * const opname = SvPV(args[i], len); SV *bitspec = get_op_bitspec(aTHX_ opname, len, 1); @@ -466,7 +467,8 @@ PPCODE: const int myopcode = SvIV(bitspec); if (myopcode < 0 || myopcode >= PL_maxo) croak("panic: opcode %d (%s) out of range",myopcode,opname); - XPUSHs(sv_2mortal(newSVpv(op_desc[myopcode], 0))); + XPUSHs(newSVpvn_flags(op_desc[myopcode], strlen(op_desc[myopcode]), + SVs_TEMP)); } else if (SvPOK(bitspec) && SvCUR(bitspec) == (STRLEN)opset_len) { int b, j; @@ -476,7 +478,9 @@ PPCODE: const U16 bits = bitmap[b]; for (j=0; j < 8 && myopcode < PL_maxo; j++, myopcode++) if (bits & (1 << j)) - XPUSHs(sv_2mortal(newSVpv(op_desc[myopcode], 0))); + XPUSHs(newSVpvn_flags(op_desc[myopcode], + strlen(op_desc[myopcode]), + SVs_TEMP)); } } else diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs index 392ba12..eccbb31 100644 --- a/ext/POSIX/POSIX.xs +++ b/ext/POSIX/POSIX.xs @@ -1457,7 +1457,7 @@ nice(incr) errno = 0; if ((incr = nice(incr)) != -1 || errno == 0) { if (incr == 0) - XPUSHs(sv_2mortal(newSVpvn("0 but true", 10))); + XPUSHs(newSVpvs_flags("0 but true", SVs_TEMP)); else XPUSHs(sv_2mortal(newSViv(incr))); } @@ -1512,11 +1512,11 @@ uname() struct utsname buf; if (uname(&buf) >= 0) { EXTEND(SP, 5); - PUSHs(sv_2mortal(newSVpv(buf.sysname, 0))); - PUSHs(sv_2mortal(newSVpv(buf.nodename, 0))); - PUSHs(sv_2mortal(newSVpv(buf.release, 0))); - PUSHs(sv_2mortal(newSVpv(buf.version, 0))); - PUSHs(sv_2mortal(newSVpv(buf.machine, 0))); + PUSHs(newSVpvn_flags(buf.sysname, strlen(buf.sysname), SVs_TEMP)); + PUSHs(newSVpvn_flags(buf.nodename, strlen(buf.nodename), SVs_TEMP)); + PUSHs(newSVpvn_flags(buf.release, strlen(buf.release), SVs_TEMP)); + PUSHs(newSVpvn_flags(buf.version, strlen(buf.version), SVs_TEMP)); + PUSHs(newSVpvn_flags(buf.machine, strlen(buf.machine), SVs_TEMP)); } #else uname((char *) 0); /* A stub to call not_here(). */ @@ -1813,8 +1813,8 @@ void tzname() PPCODE: EXTEND(SP,2); - PUSHs(sv_2mortal(newSVpvn(tzname[0],strlen(tzname[0])))); - PUSHs(sv_2mortal(newSVpvn(tzname[1],strlen(tzname[1])))); + PUSHs(newSVpvn_flags(tzname[0], strlen(tzname[0]), SVs_TEMP)); + PUSHs(newSVpvn_flags(tzname[1], strlen(tzname[1]), SVs_TEMP)); SysRet access(filename, mode) diff --git a/ext/PerlIO-via/via.pm b/ext/PerlIO-via/via.pm index 53d4358..077f0d1 100644 --- a/ext/PerlIO-via/via.pm +++ b/ext/PerlIO-via/via.pm @@ -1,5 +1,5 @@ package PerlIO::via; -our $VERSION = '0.08'; +our $VERSION = '0.09'; use XSLoader (); XSLoader::load 'PerlIO::via'; 1; diff --git a/ext/PerlIO-via/via.xs b/ext/PerlIO-via/via.xs index fd5234a..a811578 100644 --- a/ext/PerlIO-via/via.xs +++ b/ext/PerlIO-via/via.xs @@ -155,7 +155,7 @@ PerlIOVia_pushed(pTHX_ PerlIO * f, const char *mode, SV * arg, /* binmode() passes NULL - so find out what mode is */ mode = PerlIO_modestr(f,lmode); } - modesv = sv_2mortal(newSVpvn(mode, strlen(mode))); + modesv = newSVpvn_flags(mode, strlen(mode), SVs_TEMP); result = PerlIOVia_method(aTHX_ f, MYMethod(PUSHED), G_SCALAR, modesv, Nullsv); if (result) { @@ -395,7 +395,7 @@ SSize_t PerlIOVia_unread(pTHX_ PerlIO * f, const void *vbuf, Size_t count) { PerlIOVia *s = PerlIOSelf(f, PerlIOVia); - SV *buf = sv_2mortal(newSVpvn((char *) vbuf, count)); + SV *buf = newSVpvn_flags((char *) vbuf, count, SVs_TEMP); SV *result = PerlIOVia_method(aTHX_ f, MYMethod(UNREAD), G_SCALAR, buf, Nullsv); if (result) diff --git a/ext/Socket/Makefile.PL b/ext/Socket/Makefile.PL index 0389b70..d95d916 100644 --- a/ext/Socket/Makefile.PL +++ b/ext/Socket/Makefile.PL @@ -65,7 +65,7 @@ foreach qw (MSG_CTRUNC MSG_DONTROUTE MSG_OOB MSG_PEEK MSG_PROXY SCM_RIGHTS); push @names, {name => $_, type => "SV", pre=>"struct in_addr ip_address; ip_address.s_addr = htonl($_);", - value => "sv_2mortal(newSVpvn((char *)&ip_address,sizeof ip_address ))",} + value => "newSVpvn_flags((char *)&ip_address,sizeof(ip_address), SVs_TEMP)",} foreach qw(INADDR_ANY INADDR_LOOPBACK INADDR_NONE INADDR_BROADCAST); WriteConstants( diff --git a/ext/Socket/Socket.pm b/ext/Socket/Socket.pm index 1a0b7c3..ac7866a 100644 --- a/ext/Socket/Socket.pm +++ b/ext/Socket/Socket.pm @@ -1,7 +1,7 @@ package Socket; our($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); -$VERSION = "1.84"; +$VERSION = "1.85"; =head1 NAME diff --git a/ext/Socket/Socket.xs b/ext/Socket/Socket.xs index 16b893b..339b771 100644 --- a/ext/Socket/Socket.xs +++ b/ext/Socket/Socket.xs @@ -276,7 +276,7 @@ inet_ntoa(ip_address_sv) ((addr.s_addr >> 16) & 0xFF), ((addr.s_addr >> 8) & 0xFF), ( addr.s_addr & 0xFF)); - ST(0) = sv_2mortal(newSVpvn(addr_str, strlen(addr_str))); + ST(0) = newSVpvn_flags(addr_str, strlen(addr_str), SVs_TEMP); Safefree(addr_str); } @@ -347,7 +347,7 @@ pack_sockaddr_un(pathname) } else { addr_len = sizeof sun_ad; } - ST(0) = sv_2mortal(newSVpvn((char *)&sun_ad, addr_len)); + ST(0) = newSVpvn_flags((char *)&sun_ad, addr_len, SVs_TEMP); #else ST(0) = (SV *) not_here("pack_sockaddr_un"); #endif @@ -392,7 +392,7 @@ unpack_sockaddr_un(sun_sv) && addr_len < sizeof addr.sun_path; addr_len++); } - ST(0) = sv_2mortal(newSVpvn(addr.sun_path, addr_len)); + ST(0) = newSVpvn_flags(addr.sun_path, addr_len, SVs_TEMP); #else ST(0) = (SV *) not_here("unpack_sockaddr_un"); #endif @@ -425,7 +425,7 @@ pack_sockaddr_in(port, ip_address_sv) sin.sin_family = AF_INET; sin.sin_port = htons(port); sin.sin_addr.s_addr = htonl(addr.s_addr); - ST(0) = sv_2mortal(newSVpvn((char *)&sin, sizeof sin)); + ST(0) = newSVpvn_flags((char *)&sin, sizeof (sin), SVs_TEMP); } void @@ -455,7 +455,7 @@ unpack_sockaddr_in(sin_sv) EXTEND(SP, 2); PUSHs(sv_2mortal(newSViv((IV) port))); - PUSHs(sv_2mortal(newSVpvn((char *)&ip_address, sizeof ip_address))); + PUSHs(newSVpvn_flags((char *)&ip_address, sizeof(ip_address), SVs_TEMP)); } void @@ -481,7 +481,7 @@ inet_ntop(af, ip_address_sv) Copy( ip_address, &addr, sizeof addr, char ); inet_ntop(af, &addr, str, INET6_ADDRSTRLEN); - ST(0) = sv_2mortal(newSVpv(str, strlen(str))); + ST(0) = newSVpvn_flags(str, strlen(str), SVs_TEMP); #else ST(0) = (SV *)not_here("inet_ntop"); #endif