diff options
author | Nicholas Clark <nick@ccl4.org> | 2007-12-26 18:12:32 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2007-12-26 18:12:32 +0000 |
commit | 43230e26bd52e1dcdb541bb4a927c941262b74ed (patch) | |
tree | 208c0810033bd66cd36c0a5902f52f146d6c02b1 /sv.h | |
parent | dd48e7ab8eb6069673c480ccd5a1f28dca88269b (diff) | |
download | perl-43230e26bd52e1dcdb541bb4a927c941262b74ed.tar.gz |
Take code that occurs in three places to take a scalar and ready it to
hold a reference, and convert it to a macro define prepare_SV_for_RV().
p4raw-id: //depot/perl@32737
Diffstat (limited to 'sv.h')
-rw-r--r-- | sv.h | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -1441,6 +1441,20 @@ the scalar's value cannot change unless written to. } \ } STMT_END +#ifdef PERL_CORE +/* Code that crops up in three places to take a scalar and ready it to hold + a reference */ +# define prepare_SV_for_RV(sv) \ + STMT_START { \ + if (SvTYPE(sv) < SVt_PV && SvTYPE(sv) != SVt_IV) \ + sv_upgrade(sv, SVt_IV); \ + else if (SvPVX_const(sv)) { \ + SvPV_free(sv); \ + SvLEN_set(sv, 0); \ + SvCUR_set(sv, 0); \ + } \ + } STMT_END +#endif #define PERL_FBM_TABLE_OFFSET 1 /* Number of bytes between EOS and table */ |