summaryrefslogtreecommitdiff
path: root/mg.c
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>1999-05-10 19:33:36 +0000
committerGurusamy Sarathy <gsar@cpan.org>1999-05-10 19:33:36 +0000
commit810b8aa5436a934d1a2016588cbacf9b55463c40 (patch)
treeeabed90b74c878cc77d9ec21c13c0263fcc798a1 /mg.c
parent885f9e59968d66740b5c621739ead374e8e37a2b (diff)
downloadperl-810b8aa5436a934d1a2016588cbacf9b55463c40.tar.gz
"weak" references internals, still needs perlguts documentation
(somewhat modified version of patch suggested by Tuomas J. Lukka <lukka@fas.harvard.edu>) p4raw-id: //depot/perl@3385
Diffstat (limited to 'mg.c')
-rw-r--r--mg.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/mg.c b/mg.c
index 3584dbc92d..9183104339 100644
--- a/mg.c
+++ b/mg.c
@@ -1589,6 +1589,27 @@ vivify_defelem(SV *sv)
}
int
+magic_killbackrefs(SV *sv, MAGIC *mg)
+{
+ AV *av = (AV*)mg->mg_obj;
+ SV **svp = AvARRAY(av);
+ I32 i = AvFILLp(av);
+ while (i >= 0) {
+ if (svp[i] && svp[i] != &PL_sv_undef) {
+ if (!SvWEAKREF(svp[i]))
+ croak("panic: magic_killbackrefs");
+ /* XXX Should we check that it hasn't changed? */
+ SvRV(svp[i]) = 0;
+ SvOK_off(svp[i]);
+ SvWEAKREF_off(svp[i]);
+ svp[i] = &PL_sv_undef;
+ }
+ i--;
+ }
+ return 0;
+}
+
+int
magic_setmglob(SV *sv, MAGIC *mg)
{
mg->mg_len = -1;