This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
clarify when HV backref is in magic
authorDavid Mitchell <davem@iabyn.com>
Sun, 1 Aug 2010 20:39:39 +0000 (21:39 +0100)
committerDavid Mitchell <davem@iabyn.com>
Sun, 1 Aug 2010 20:47:31 +0000 (21:47 +0100)
Fix up the comments in and above some functions to clarify that backref
bagic for hVs may sometimes be moved back to HvAUX.

hv.c
sv.c

diff --git a/hv.c b/hv.c
index 9b5a3ba..e221499 100644 (file)
--- a/hv.c
+++ b/hv.c
@@ -1678,8 +1678,10 @@ S_hfreeentries(pTHX_ HV *hv)
             * If, during the entry freeing, a destructor happens to add
             * a new weak backref, then sv_add_backref will look in both
             * places (magic in HvAUX) for the AV, but will create a new
-            * AV in HvAUX if it can't find one. So at the end of the
-            * iteration we have to allow for this. */
+            * AV in HvAUX if it can't find one (if it finds it in magic,
+            * it moves it back into HvAUX. So at the end of the iteration
+            * we have to allow for this. */
+
 
            if (iter->xhv_backreferences) {
                if (SvTYPE(iter->xhv_backreferences) == SVt_PVAV) {
diff --git a/sv.c b/sv.c
index 5d744c5..a2f9867 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -5310,6 +5310,8 @@ Perl_sv_rvweaken(pTHX_ SV *const sv)
  * store it directly in the HvAUX or mg_obj slot, avoiding the need to
  * allocate an AV. (Whether the slot holds an AV tells us whether this is
  * active.)
+ *
+ * If an HV's backref is stored in magic, it is moved back to HvAUX.
  */
 
 /* A discussion about the backreferences array and its refcount:
@@ -5420,10 +5422,6 @@ Perl_sv_del_backref(pTHX_ SV *const tsv, SV *const sv)
 
     if (SvTYPE(tsv) == SVt_PVHV && SvOOK(tsv)) {
        svp = (SV**)Perl_hv_backreferences_p(aTHX_ MUTABLE_HV(tsv));
-       /* We mustn't attempt to "fix up" the hash here by moving the
-          backreference array back to the hv_aux structure, as that is stored
-          in the main HvARRAY(), and hfreentries assumes that no-one
-          reallocates HvARRAY() while it is running.  */
     }
     if (!svp || !*svp) {
        MAGIC *const mg