]> git.vpit.fr Git - perl/modules/autovivification.git/blobdiff - autovivification.xs
Update VPIT::XSHelpers to 18554226
[perl/modules/autovivification.git] / autovivification.xs
index a744b79be8a735ef0c47af4c153597cb92a4a7e9..3f0eba1293530d1b6413c4a7e0d7e85e0d871db3 100644 (file)
@@ -118,7 +118,7 @@ typedef struct {
 } a_op_info;
 
 #define PTABLE_NAME             ptable_map
-#define PTABLE_VAL_FREE(V)      PerlMemShared_free(V)
+#define PTABLE_VAL_FREE(V)      XSH_SHARED_FREE((V), 1, a_op_info)
 #define PTABLE_VAL_NEED_CONTEXT 0
 #define PTABLE_NEED_DELETE      1
 #define PTABLE_NEED_WALK        0
@@ -168,7 +168,7 @@ static const a_op_info *a_map_store_locked(pPMS_ const OP *o, OP *(*old_pp)(pTHX
  a_op_info *oi;
 
  if (!(oi = ptable_fetch(a_op_map, o))) {
-  oi = PerlMemShared_malloc(sizeof *oi);
+  XSH_SHARED_ALLOC(oi, 1, a_op_info);
   ptable_map_store(a_op_map, o, oi);
  }
 
@@ -238,17 +238,18 @@ static void a_map_store_root(pTHX_ const OP *root, OP *(*old_pp)(pTHX), UV flags
  return;
 }
 
-static void a_map_update_flags_topdown(const OP *root, UV flags) {
+static void a_map_update_flags_topdown(const OP *root, UV mask, UV flags) {
  a_op_info *oi;
  const OP *o = root;
 
  XSH_LOCK(&a_op_map_mutex);
 
- flags &= ~A_HINT_ROOT;
+ mask  |= A_HINT_ROOT;
+ flags &= ~mask;
 
  do {
   if ((oi = ptable_fetch(a_op_map, o)))
-   oi->flags = (oi->flags & (A_HINT_ROOT|A_HINT_SECOND)) | flags;
+   oi->flags = (oi->flags & mask) | flags;
   if (!(o->op_flags & OPf_KIDS))
    break;
   o = a_map_descend(o);
@@ -259,8 +260,6 @@ static void a_map_update_flags_topdown(const OP *root, UV flags) {
  return;
 }
 
-#define a_map_cancel(R) a_map_update_flags_topdown((R), 0)
-
 static void a_map_update_flags_bottomup(const OP *o, UV flags, UV rflags) {
  a_op_info *oi;
 
@@ -1058,11 +1057,11 @@ static OP *a_ck_root(pTHX_ OP *o) {
     }
    }
 #endif
-   a_map_update_flags_topdown(o, hint | A_HINT_DEREF);
+   a_map_update_flags_topdown(o, A_HINT_SECOND, hint | A_HINT_DEREF);
    a_map_store_root(o, o->op_ppaddr, hint);
    o->op_ppaddr = new_pp;
   } else {
-   a_map_cancel(o);
+   a_map_update_flags_topdown(o, 0, 0);
   }
  } else
   a_map_delete(o);