diff options
author | Yves Orton <demerphq@gmail.com> | 2023-03-16 18:40:35 +0100 |
---|---|---|
committer | Yves Orton <demerphq@gmail.com> | 2023-03-18 20:57:59 +0800 |
commit | 6dd040ff2f6f01a817731d112756188ddb541a18 (patch) | |
tree | a78475aea0b7c8ea6e0e05afd8a11db1ea6a2823 /sv_inline.h | |
parent | e2e830cd93e16aedc6c6225069eeb7bdfc431a43 (diff) | |
download | perl-6dd040ff2f6f01a817731d112756188ddb541a18.tar.gz |
sv.h - add SvREFCNT_dec_set_NULL()
and also SvREFCNT_dec_ret_NULL() which is used to implement
SvREFCNT_dec_set_NULL(). The set_NULL() macro is intended to
be used to replace code like this:
if (sv) {
SvREFCNT_dec_NN(sv);
sv = NULL;
}
The function form just facilitates it, and can be used in situations
where returning NULL after decrementing a refcount would be reduce
code complexity.
Diffstat (limited to 'sv_inline.h')
-rw-r--r-- | sv_inline.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/sv_inline.h b/sv_inline.h index 1bb8c2897d..3adc130575 100644 --- a/sv_inline.h +++ b/sv_inline.h @@ -664,6 +664,7 @@ Perl_SvREFCNT_inc(SV *sv) SvREFCNT(sv)++; return sv; } + PERL_STATIC_INLINE SV * Perl_SvREFCNT_inc_NN(SV *sv) { @@ -672,12 +673,14 @@ Perl_SvREFCNT_inc_NN(SV *sv) SvREFCNT(sv)++; return sv; } + PERL_STATIC_INLINE void Perl_SvREFCNT_inc_void(SV *sv) { if (LIKELY(sv != NULL)) SvREFCNT(sv)++; } + PERL_STATIC_INLINE void Perl_SvREFCNT_dec(pTHX_ SV *sv) { @@ -690,6 +693,15 @@ Perl_SvREFCNT_dec(pTHX_ SV *sv) } } +PERL_STATIC_INLINE SV * +Perl_SvREFCNT_dec_ret_NULL(pTHX_ SV *sv) +{ + PERL_ARGS_ASSERT_SVREFCNT_DEC_RET_NULL; + Perl_SvREFCNT_dec(aTHX_ sv); + return NULL; +} + + PERL_STATIC_INLINE void Perl_SvREFCNT_dec_NN(pTHX_ SV *sv) { |