# define mPUSHu(U) PUSHs(sv_2mortal(newSVuv(U)))
#endif
+#ifndef SvPV_const
+# define SvPV_const SvPV
+#endif
+
#ifndef PERL_MAGIC_ext
# define PERL_MAGIC_ext '~'
#endif
}
STATIC int vmg_svt_free(pTHX_ SV *sv, MAGIC *mg) {
- SV *wiz = (SV *) mg->mg_ptr;
const MGWIZ *w;
unsigned int flags;
int ret = 0;
- /* This may happen in global destruction */
- if (SvTYPE(wiz) == SVTYPEMASK)
+ /* Don't even bother if we are in global destruction - the wizard is prisoner
+ * of circular references and we are way beyond user realm */
+ if (PL_dirty)
return 0;
w = SV2MGWIZ(mg->mg_ptr);
STRLEN len;
char *sig = HePV(key, len);
SV *sv;
+ const MGWIZ *w;
MAGIC *mg;
- sv = MGWIZ2SV(vmg_wizard_clone(SV2MGWIZ(HeVAL(key))));
+ w = SV2MGWIZ(HeVAL(key));
+ w = vmg_wizard_clone(w);
+ sv = MGWIZ2SV(w);
mg = sv_magicext(sv, NULL, PERL_MAGIC_ext, &vmg_wizard_vtbl, NULL, 0);
mg->mg_private = SIG_WIZ;
SvREADONLY_on(sv);