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

Re: Missing core function: sv_setrv()

Thread Previous | Thread Next
Paul "LeoNerd" Evans
April 16, 2020 18:04
Re: Missing core function: sv_setrv()
Message ID:
On Wed, 18 Mar 2020 16:24:37 +0000
"Paul \"LeoNerd\" Evans" <> wrote:

> 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?

Update: This appears to do the trick:

  #define sv_setrv(s, r)  S_sv_setrv(aTHX_ s, r)
  static void S_sv_setrv(pTHX_ SV *sv, SV *rv)
    sv_upgrade(sv, SVt_IV);
    SvIV_set(sv, 0);
    SvRV_set(sv, rv);

At least, it's sufficient for newly-created blank SVs such as with:

  SV **svp = hv_fetchs(hv, "key", 1);
    sv_setrv(*svp, newAV());

The search continues...

Paul "LeoNerd" Evans      |  |

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