On Wed, 18 Mar 2020 16:24:37 +0000 "Paul \"LeoNerd\" Evans" <leonerd@leonerd.org.uk> 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); SvROK_on(sv); 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); if(!SvROK(*svp)) sv_setrv(*svp, newAV()); The search continues... -- Paul "LeoNerd" Evans leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/Thread Previous | Thread Next