diff options
author | David Mitchell <davem@iabyn.com> | 2010-07-18 15:07:08 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2010-07-18 18:39:18 +0100 |
commit | cfc1e951d98ba2b9a0e066aba9aadba4cd919eec (patch) | |
tree | 035e1c687d0f681990220c6e3f4db9317252fd3e /gv.c | |
parent | 00c0cb6d254eaba165c8445a6e68686b8285b5a3 (diff) | |
download | perl-cfc1e951d98ba2b9a0e066aba9aadba4cd919eec.tar.gz |
add CVf_CVGV_RC flag
after the recent commit 803f274831f937654d48f8cf0468521cbf8f5dff,
the CvGV field is sometimes reference counted. Since it was intended that
the reference counting would happen only for anonymous CVs, the CVf_ANON
flag was co-opted to indicate whether RC was being used. This is not
entirely robust; for example, sub __ANON__ {} is a non-anon sub which
points to the same GV used by anon subs, which while itself doesn't
directly break things, shows that the potential for breakage is there.
So add a separate flag just to indicate the reference count status of the
CvGV field.
Diffstat (limited to 'gv.c')
-rw-r--r-- | gv.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -206,10 +206,11 @@ Perl_cvgv_set(pTHX_ CV* cv, GV* gv) return; if (oldgv) { - if (CvANON(cv)) + if (CvCVGV_RC(cv)) { SvREFCNT_dec(oldgv); + CvCVGV_RC_off(cv); + } else { - assert(strNE(GvNAME(oldgv),"__ANON__")); sv_del_backref(MUTABLE_SV(oldgv), MUTABLE_SV(cv)); } } @@ -220,11 +221,10 @@ Perl_cvgv_set(pTHX_ CV* cv, GV* gv) return; if (CvANON(cv)) { - assert(strnEQ(GvNAME(gv),"__ANON__", 8)); + CvCVGV_RC_on(cv); SvREFCNT_inc_simple_void_NN(gv); } else { - assert(strNE(GvNAME(gv),"__ANON__")); Perl_sv_add_backref(aTHX_ MUTABLE_SV(gv), MUTABLE_SV(cv)); } } |