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

Re: New SV Flag

Thread Previous | Thread Next
From:
Arthur Bergman
Date:
February 10, 2003 11:59
Subject:
Re: New SV Flag
Message ID:
336458AB-3D32-11D7-8E65-003065D64CBE@contiller.se

On torsdag, feb 6, 2003, at 13:15 Europe/Stockholm, 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.
>
> Alternatively, mg_free currently always returns zero.
> Perhaps it could return some flags based on some magic flags.
> Thus magic flags could be used as an extension of sv flags
> for the purpose of influencing the death of an sv.
>
> Tim.
>

Hi,

I think the check is there for objects that have DESTROYS that increase 
the refcount, there should be a test for this!

I think that by letting my magic increase the refcount, free the 
original body, set a fake body, and then return and put the head in a 
free list to be reused.

So no flag needed! Thanks.

Arthur


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About