1################################################################################ 2## 3## Version 3.x, Copyright (C) 2004-2013, Marcus Holland-Moritz. 4## Version 2.x, Copyright (C) 2001, Paul Marquess. 5## Version 1.x, Copyright (C) 1999, Kenneth Albanowski. 6## 7## This program is free software; you can redistribute it and/or 8## modify it under the same terms as Perl itself. 9## 10################################################################################ 11 12=provides 13 14newRV_inc 15newRV_noinc 16 17=implementation 18 19__UNDEFINED__ newRV_inc(sv) newRV(sv) /* Replace */ 20 21#ifndef newRV_noinc 22#if defined(PERL_USE_GCC_BRACE_GROUPS) 23# define newRV_noinc(sv) ({ SV *_sv = (SV *)newRV((sv)); SvREFCNT_dec((sv)); _sv; }) 24#else 25# define newRV_noinc(sv) ((PL_Sv = (SV *)newRV((sv))), SvREFCNT_dec((sv)), PL_Sv) 26#endif 27#endif 28 29=xsubs 30 31U32 32newRV_inc_REFCNT() 33 PREINIT: 34 SV *sv, *rv; 35 CODE: 36 sv = newSViv(42); 37 rv = newRV_inc(sv); 38 SvREFCNT_dec(sv); 39 RETVAL = SvREFCNT(sv); 40 sv_2mortal(rv); 41 OUTPUT: 42 RETVAL 43 44U32 45newRV_noinc_REFCNT() 46 PREINIT: 47 SV *sv, *rv; 48 CODE: 49 sv = newSViv(42); 50 rv = newRV_noinc(sv); 51 RETVAL = SvREFCNT(sv); 52 sv_2mortal(rv); 53 OUTPUT: 54 RETVAL 55 56=tests plan => 2 57 58is(&Devel::PPPort::newRV_inc_REFCNT, 1); 59is(&Devel::PPPort::newRV_noinc_REFCNT, 1); 60