develooper Front page | perl.perl5.porters | Postings from March 2020

Missing core function: sv_setrv()

Thread Next
Paul "LeoNerd" Evans
March 18, 2020 16:24
Missing core function: sv_setrv()
Message ID:
I'm trying to do the following in a bit of XS code:

  CV *cv = ...;
  sv_setrv(get_sv("Some::Package::VAR", GV_ADD), (SV *)cv);

this fails because there isn't an sv_setrv(). I vote it should be added.

However, I'm struggling to find a sensible implementation for it. A
hacked-up version that does work just fine is:

  static void sv_setrv(SV *sv, SV *rv)
    SV *tmp = newRV_noinc(rv);
    sv_setsv(sv, tmp);

but of course this is rather silly having to create and throw away that

I've tried hunting around perl core for various bits to copypaste, but
lots of tempting ideas end up containing macros that are #ifdef
PERL_CORE so I can't see them from XS.

Can anyone suggest something better?

Paul "LeoNerd" Evans      |  |

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