in reply to XS, pointer scope, strings, allocation responsibility, sv_setpv, SvPV, pack's pointer

Hopefull this will help you answer some of your questions

perlapi

sv_setpv     Copies a string into an SV...

sv_setpvn     Copies a string into an SV...

PerlGuts Illustrated

define SvPVX

70 /* safe version of free */ 71 72 Free_t 73 safefree(Malloc_t where) 74 { 75 #ifdef DEBUGGING 76 if (debug & 128) 77 fprintf(stderr,"0x%lx: (%05d) free\n",(unsigned long)wher +e,an++); 78 #endif 79 free(where); 80 }
  • Comment on Re: XS, pointer scope, strings, allocation responsibility, sv_setpv, SvPV, pack's pointer
  • Download Code

Replies are listed 'Best First'.
Re^2: XS, pointer scope, strings, allocation responsibility, sv_setpv, SvPV, pack's pointer
by Tux (Canon) on Oct 24, 2010 at 10:50 UTC

    The macro's can expand to other macro's that expand to other macro's ...:

    perl-current $ ./perl -Ilib Porting/expand-macro.pl SvPVX `sh cflags "optimize='-O2 -g'" try.c` -E try.c > try.i CCCMD = ccache g++ -DPERL_CORE -c -D_REENTRANT -D_GNU_SOURC +E -fPIC -DDEBUGGING -DDEBUGGING -fno-strict-aliasing -pipe -fstack-pr +otector -I/pro/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS= +64 -O2 -g -Wall -ansi -W -Wextra -Wendif-labels -Wwrite-strings -Wn +o-unused-variable -Wno-unused-parameter # 4 "SvPVX expands to" (*({ SV *const _svpvx = ((SV *)({ void *_p = (A0); _p; })); ((((svtype +)((_svpvx)->sv_flags & 0xff)) >= SVt_PV) ? static_cast<void> (0) : __ +assert_fail ("((svtype)((_svpvx)->sv_flags & 0xff)) >= SVt_PV", "SvPV +X expands to", 4, __PRETTY_FUNCTION__)); ((((svtype)((_svpvx)->sv_fla +gs & 0xff)) != SVt_PVAV) ? static_cast<void> (0) : __assert_fail ("(( +svtype)((_svpvx)->sv_flags & 0xff)) != SVt_PVAV", "SvPVX expands to", + 4, __PRETTY_FUNCTION__)); ((((svtype)((_svpvx)->sv_flags & 0xff)) != + SVt_PVHV) ? static_cast<void> (0) : __assert_fail ("((svtype)((_svpv +x)->sv_flags & 0xff)) != SVt_PVHV", "SvPVX expands to", 4, __PRETTY_F +UNCTION__)); ((!((((_svpvx)->sv_flags & (0x00004000|0x00008000)) == 0 +x00008000) && (((svtype)((_svpvx)->sv_flags & 0xff)) == SVt_PVGV || ( +(svtype)((_svpvx)->sv_flags & 0xff)) == SVt_PVLV))) ? static_cast<voi +d> (0) : __assert_fail ("!((((_svpvx)->sv_flags & (0x00004000|0x00008 +000)) == 0x00008000) && (((svtype)((_svpvx)->sv_flags & 0xff)) == SVt +_PVGV || ((svtype)((_svpvx)->sv_flags & 0xff)) == SVt_PVLV))", "SvPVX + expands to", 4, __PRETTY_FUNCTION__)); ((!(((svtype)((_svpvx)->sv_fl +ags & 0xff)) == SVt_PVIO && !(((XPVIO*) (_svpvx)->sv_any)->xio_flags +& 64))) ? static_cast<void> (0) : __assert_fail ("!(((svtype)((_svpvx +)->sv_flags & 0xff)) == SVt_PVIO && !(((XPVIO*) (_svpvx)->sv_any)->xi +o_flags & 64))", "SvPVX expands to", 4, __PRETTY_FUNCTION__)); &((_sv +pvx)->sv_u.svu_pv); }))

    Sometimes that helps but sometimes it just obfuscates more then it explains


    Enjoy, Have FUN! H.Merijn