develooper Front page | perl.perl5.porters | Postings from August 2022

CV flag for refcounted CvXSUBANY.any_sv

Thread Next
From:
Paul "LeoNerd" Evans
Date:
August 8, 2022 17:51
Subject:
CV flag for refcounted CvXSUBANY.any_sv
Message ID:
20220808185137.582d33aa@shy.leonerd.org.uk
XSUBs provide an ANY union that code can store whatever it wants, to be
later accessed within the CV body. Being an ANY union, one of the
possibilities is to store an SV pointer in there. This is fairly common
(at least, in my code).

Since it stores an SV pointer, you need to arrange for it to be
SvREFCNT_dec'ed when the CV itself is destroyed (e.g. perhaps the CV is
an anonymous closure).

Perl doesn't currently provide a facility for this, meaning I end up
having to do annoying magic on the CV just to make it happen at the
right time.

I'm thinking of adding a CV flag to tell Perl to do that automatically.
When clearing an SV it can then use

  if(FLAG)
    SvREFCNT_dec(CvXSUBANY(cv).any_sv);


Thoughts anyone?

-- 
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk      |  https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/  |  https://www.tindie.com/stores/leonerd/

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