]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blobdiff - Magic.xs
Don't even define a CLONE sub when the module isn't thread safe
[perl/modules/Variable-Magic.git] / Magic.xs
index dfce918d55c300915f07bcf212a47e538912462d..5b4576aed6b1da7f3dfdc55e987aeb52495034a3 100644 (file)
--- a/Magic.xs
+++ b/Magic.xs
@@ -550,7 +550,6 @@ STATIC U32 vmg_svt_len(pTHX_ SV *sv, MAGIC *mg) {
  U32 ret;
 
  dSP;
- int count;
 
  has_array = SvTYPE(sv) == SVt_PVAV;
 
@@ -570,7 +569,7 @@ STATIC U32 vmg_svt_len(pTHX_ SV *sv, MAGIC *mg) {
  }
  PUTBACK;
 
- count = call_sv(SV2MGWIZ(mg->mg_ptr)->cb_len, G_SCALAR);
+ call_sv(SV2MGWIZ(mg->mg_ptr)->cb_len, G_SCALAR);
 
  SPAGAIN;
  svr = POPs;
@@ -595,7 +594,7 @@ STATIC int vmg_svt_free(pTHX_ SV *sv, MAGIC *mg) {
  if (SvTYPE(wiz) == SVTYPEMASK)
   return 0;
 
- /* So that it can survive tmp cleanup in vmg_cb_call */
+ /* So that it survives the temp cleanup in vmg_cb_call */
  SvREFCNT_inc(sv);
 
 #if !VMG_HAS_PERL_MAINT(5, 11, 0, 32686)
@@ -605,14 +604,14 @@ STATIC int vmg_svt_free(pTHX_ SV *sv, MAGIC *mg) {
  SvMAGIC_set(sv, mg);
 #endif
 
- /* Perl_mg_free will get rid of the magic and decrement mg->mg_obj and
-  * mg->mg_ptr reference count */
  ret = vmg_cb_call1e(SV2MGWIZ(wiz)->cb_free, sv, mg->mg_obj);
 
  /* Calling SvREFCNT_dec() will trigger destructors in an infinite loop, so
   * we have to rely on SvREFCNT() being a lvalue. Heck, even the core does it */
  --SvREFCNT(sv);
 
+ /* Perl_mg_free will get rid of the magic and decrement mg->mg_obj and
+  * mg->mg_ptr reference count */
  return ret;
 }
 
@@ -695,7 +694,7 @@ STATIC I32 vmg_svt_val(pTHX_ IV action, SV *sv) {
     continue;
    case 2:
     if (!newkey)
-     newkey = key = umg->mg_obj = sv_2mortal(newSVsv(umg->mg_obj));
+     newkey = key = umg->mg_obj = sv_mortalcopy(umg->mg_obj);
   }
   switch (action) {
    case 0:
@@ -972,13 +971,14 @@ BOOT:
  newCONSTSUB(stash, "VMG_THREADSAFE",      newSVuv(VMG_THREADSAFE));
 }
 
+#if VMG_THREADSAFE
+
 void
 CLONE(...)
 PROTOTYPE: DISABLE
 PREINIT:
  HV *hv;
 CODE:
-#if VMG_THREADSAFE
  {
   HE *key;
   dMY_CXT;
@@ -1001,6 +1001,7 @@ CODE:
   MY_CXT_CLONE;
   MY_CXT = hv;
  }
+
 #endif /* VMG_THREADSAFE */
 
 SV *_wizard(...)