diff options
author | Ilya Zakharevich <ilya@math.berkeley.edu> | 2000-12-04 19:40:25 -0500 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2000-12-05 15:52:34 +0000 |
commit | 840a7b70755d06740715e982aa756f9d77203c4e (patch) | |
tree | 41e2a532a3c399c925ded4bdcf51a1beb2fec50d /sv.c | |
parent | 4c80c0b28d91ade6a9768a49b70f648aabec579b (diff) | |
download | perl-840a7b70755d06740715e982aa756f9d77203c4e.tar.gz |
Re: [PATCH] The largest hoax of all times?
Date: Tue, 5 Dec 2000 00:40:25 -0500
Message-ID: <20001205004025.A4050@monk.mps.ohio-state.edu>
Subject: Re: [PATCH] The largest hoax of all times?
From: Ilya Zakharevich <ilya@math.ohio-state.edu>
Date: Mon, 4 Dec 2000 23:55:53 -0500
Message-ID: <20001204235553.A1140@monk.mps.ohio-state.edu>
Subject: Re: [PATCH] The largest hoax of all times?
From: Ilya Zakharevich <ilya@math.ohio-state.edu>
Date: Tue, 5 Dec 2000 01:28:45 -0500
Message-ID: <20001205012844.A4227@monk.mps.ohio-state.edu>
Fix the unpredictable order of DESTROYs.
p4raw-id: //depot/perl@7991
Diffstat (limited to 'sv.c')
-rw-r--r-- | sv.c | 41 |
1 files changed, 34 insertions, 7 deletions
@@ -3068,7 +3068,7 @@ Perl_sv_usepvn_mg(pTHX_ register SV *sv, register char *ptr, register STRLEN len } void -Perl_sv_force_normal(pTHX_ register SV *sv) +Perl_sv_force_normal_flags(pTHX_ register SV *sv, U32 flags) { if (SvREADONLY(sv)) { if (SvFAKE(sv)) { @@ -3086,11 +3086,17 @@ Perl_sv_force_normal(pTHX_ register SV *sv) Perl_croak(aTHX_ PL_no_modify); } if (SvROK(sv)) - sv_unref(sv); + sv_unref_flags(sv, flags); else if (SvFAKE(sv) && SvTYPE(sv) == SVt_PVGV) sv_unglob(sv); } +void +Perl_sv_force_normal(pTHX_ register SV *sv) +{ + sv_force_normal_flags(sv, 0); +} + /* =for apidoc sv_chop @@ -5692,17 +5698,21 @@ S_sv_unglob(pTHX_ SV *sv) } /* -=for apidoc sv_unref +=for apidoc sv_unref_flags Unsets the RV status of the SV, and decrements the reference count of whatever was being referenced by the RV. This can almost be thought of -as a reversal of C<newSVrv>. See C<SvROK_off>. +as a reversal of C<newSVrv>. The C<cflags> argument can contain +C<SV_IMMEDIATE_UNREF> to force the reference count to be decremented +(otherwise the decrementing is conditional on the reference count being +different from one or the reference being a readonly SV). +See C<SvROK_off>. =cut */ void -Perl_sv_unref(pTHX_ SV *sv) +Perl_sv_unref_flags(pTHX_ SV *sv, U32 flags) { SV* rv = SvRV(sv); @@ -5714,12 +5724,29 @@ Perl_sv_unref(pTHX_ SV *sv) } SvRV(sv) = 0; SvROK_off(sv); - if (SvREFCNT(rv) != 1 || SvREADONLY(rv)) + if (SvREFCNT(rv) != 1 || SvREADONLY(rv) || flags) /* SV_IMMEDIATE_UNREF */ SvREFCNT_dec(rv); - else + else /* XXX Hack, but hard to make $a=$a->[1] work otherwise */ sv_2mortal(rv); /* Schedule for freeing later */ } +/* +=for apidoc sv_unref + +Unsets the RV status of the SV, and decrements the reference count of +whatever was being referenced by the RV. This can almost be thought of +as a reversal of C<newSVrv>. This is C<sv_unref_flags> with the C<flag> +being zero. See C<SvROK_off>. + +=cut +*/ + +void +Perl_sv_unref(pTHX_ SV *sv) +{ + sv_unref_flags(sv, 0); +} + void Perl_sv_taint(pTHX_ SV *sv) { |