develooper Front page | perl.perl5.porters | Postings from February 2003

Re: New SV Flag

Thread Previous | Thread Next
Nicholas Clark
February 8, 2003 11:07
Re: New SV Flag
Message ID:
On Thu, Feb 06, 2003 at 12:15:31PM +0000, Tim Bunce wrote:

> sv_free does:
>     ATOMIC_DEC_AND_TEST(refcount_is_zero, SvREFCNT(sv));
>     if (!refcount_is_zero)
>         return;
>     sv_clear(sv);
>     if (! SvREFCNT(sv))
>         del_SV(sv);
> I can't remember why the last SvREFCNT(sv) test is there
> but perhaps it could be useful for you... sv_clear calls
> mg_free, your magic destructor could test for SvREFCNT(sv)==0
> to know that the sv was about to be freed and set SvREFCNT
> to a non-zero value to prevent the final del_SV.

I find that I can take that check out without failing any regression tests.
This is somewhat bad - what is it in there for?

I have this feeling that Richard Clamp has some idea of what's going on here,
as I seem to remember him mailing a list (forget which) some games with what
happens on various perl versions if an object attempts to stop itself being

But even that doesn't explain its intended purpose.

Nicholas Clark

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About