ptable_store(ud->wizards, ent->key, w);
}
-STATIC void vmg_thread_cleanup(pTHX_ void *);
-
-STATIC void vmg_thread_cleanup(pTHX_ void *ud) {
- int *level = ud;
-
- if (*level) {
- --*level;
- LEAVE;
- SAVEDESTRUCTOR_X(vmg_thread_cleanup, level);
- ENTER;
- } else {
- dMY_CXT;
- PerlMemShared_free(level);
- ptable_free(MY_CXT.wizards);
- }
-}
#endif /* VMG_THREADSAFE */
/* --- Wizard objects ------------------------------------------------------ */
w->cb_ ## N = NULL; \
}
+#if VMG_THREADSAFE
+
+STATIC void vmg_cleanup(pTHX_ void *ud) {
+ dMY_CXT;
+
+ ptable_free(MY_CXT.wizards);
+ MY_CXT.wizards = NULL;
+}
+
+#endif /* VMG_THREADSAFE */
+
/* --- XS ------------------------------------------------------------------ */
MODULE = Variable::Magic PACKAGE = Variable::Magic
MY_CXT.b__op_stashes[0] = NULL;
#if VMG_THREADSAFE
MUTEX_INIT(&vmg_op_name_init_mutex);
+ call_atexit(vmg_cleanup, NULL);
#endif
stash = gv_stashpv(__PACKAGE__, 1);
? gv_stashpv(vmg_opclassnames[c], 1) : NULL;
}
}
- {
- int *level;
- level = PerlMemShared_malloc(sizeof *level);
- *level = 1;
- LEAVE;
- SAVEDESTRUCTOR_X(vmg_thread_cleanup, level);
- ENTER;
- }
XSRETURN(0);
#endif /* VMG_THREADSAFE */