################################################################################
##
##  $Revision: 5 $
##  $Author: mhx $
##  $Date: 2005/01/31 08:10:52 +0100 $
##
################################################################################
##
##  Version 3.x, Copyright (C) 2004-2005, Marcus Holland-Moritz.
##  Version 2.x, Copyright (C) 2001, Paul Marquess.
##  Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
##
##  This program is free software; you can redistribute it and/or
##  modify it under the same terms as Perl itself.
##
################################################################################

=provides

newRV_inc
newRV_noinc

=implementation

__UNDEFINED__  newRV_inc(sv)  newRV(sv)   /* Replace */

#ifndef newRV_noinc
#if { NEED newRV_noinc }
SV *
newRV_noinc(SV *sv)
{
  SV *rv = (SV *)newRV(sv);
  SvREFCNT_dec(sv);
  return rv;
}
#endif
#endif

=xsinit

#define NEED_newRV_noinc

=xsubs

U32
newRV_inc_REFCNT()
	PREINIT:
		SV *sv, *rv;
	CODE:
		sv = newSViv(42);
		rv = newRV_inc(sv);
		SvREFCNT_dec(sv);
		RETVAL = SvREFCNT(sv);
		sv_2mortal(rv);
	OUTPUT:
		RETVAL

U32
newRV_noinc_REFCNT()
	PREINIT:
		SV *sv, *rv;
	CODE:
		sv = newSViv(42);
		rv = newRV_noinc(sv);
		RETVAL = SvREFCNT(sv);
		sv_2mortal(rv);
	OUTPUT:
		RETVAL

=tests plan => 2

ok(&Devel::PPPort::newRV_inc_REFCNT, 1);
ok(&Devel::PPPort::newRV_noinc_REFCNT, 1);

