On Mon, Aug 8, 2022 at 7:52 PM Paul "LeoNerd" Evans <leonerd@leonerd.org.uk> wrote: > 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? > Makes sense, and there is prior art of doing such things (e.g. with the mg_ptr field of struct magic) LeonThread Previous | Thread Next