Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: where is sv_setrv?

by patcat88 (Deacon)
on Dec 17, 2011 at 16:55 UTC ( #944092=note: print w/ replies, xml ) Need Help??


in reply to Re: where is sv_setrv?
in thread where is sv_setrv?

Your version of newSVrv wouldn't work. Its only 5.12 compatible, not before, because of the SV type changes and the prepare_SV_for_RV macro changed. Can RVs have a PV string pointer (flags off of course)? Does an RV always have to be of type SVt_RV (5.10) or SVt_IV (5.12) or any SV with ROK can be a reference? The sv_replace seems like the safest idea while i'm writing this.

There is a missing refcount inc on sv before "SvRV_set(rv, sv);". Also there is a macro for the old RV sv type to IV, seems to me that it will provide backwards compatibility sv.h#l75 in perl.git


Comment on Re^2: where is sv_setrv?
Re^3: where is sv_setrv?
by ikegami (Pope) on Dec 19, 2011 at 07:20 UTC

    Your version of newSVrv wouldn't work [before Perl 5.12]

    It's not a version of newSVrv, and you're free to do the exercise yourself for 5.10.

    Can RVs have a PV string pointer

    Like you just said, there's no such thing as an RV anymore.

    Does an RV always have to be of type SVt_IV (5.12) or any SV with ROK can be a reference?

    Latter. Even before 5.12.

    The sv_replace seems like the safest idea while i'm writing this.

    That's quite an understatement.

    There is a missing refcount inc on sv before "SvRV_set(rv, sv);".

    You're saying that newSVrv causes referenced material to be destroyed permaturely. I don't believe you.

      There is a missing refcount inc on sv before "SvRV_set(rv, sv);".

      You're saying that newSVrv causes referenced material to be destroyed permaturely. I don't believe you.


      In newSVrv, a new target SV is created at sv.c#l9268 in perl.git. In a hypothetical setsv_rv you need to up the refcount of the EXISTING target SV that the reference will point to or the existing target SV will get garbage collected prematurely, and we arent making a weak reference here, or your following hv_store standard where the caller has to up the refcount (or do nothing with newSV) of the sv before passing to the func?
        Fixed.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://944092]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (11)
As of 2014-10-21 07:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (98 votes), past polls