X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=Magic.xs;h=33fc60e70e295a065e1a990fa0f878c0621ca3a3;hb=5c32c65e51fca0ff49c43b814e9653e01b1e56f1;hp=9eda482e03a65e3652c7732e63b921a0386b47da;hpb=de1bca58e695e4df40b7c597d8181cc6ca5d9bb9;p=perl%2Fmodules%2FVariable-Magic.git diff --git a/Magic.xs b/Magic.xs index 9eda482..33fc60e 100644 --- a/Magic.xs +++ b/Magic.xs @@ -133,6 +133,12 @@ # define IN_PERL_COMPILETIME (PL_curcop == &PL_compiling) #endif +#ifdef DEBUGGING +# define VMG_ASSERT(C) assert(C) +#else +# define VMG_ASSERT(C) +#endif + /* uvar magic and Hash::Util::FieldHash were commited with 28419, but we only * enable them on 5.10 */ #if VMG_HAS_PERL(5, 10, 0) @@ -488,9 +494,8 @@ static opclass vmg_opclass(const OP *o) { /* --- Error messages ------------------------------------------------------ */ -static const char vmg_invalid_wiz[] = "Invalid wizard object"; -static const char vmg_wrongargnum[] = "Wrong number of arguments"; -static const char vmg_argstorefailed[] = "Error while storing arguments"; +static const char vmg_invalid_wiz[] = "Invalid wizard object"; +static const char vmg_wrongargnum[] = "Wrong number of arguments"; /* --- Context-safe global data -------------------------------------------- */ @@ -1246,11 +1251,18 @@ static int vmg_cb_call(pTHX_ SV *cb, unsigned int flags, SV *sv, ...) { svr = POPs; if (SvOK(svr)) ret = (int) SvIV(svr); + if (SvROK(svr)) + SvREFCNT_inc(svr); + else + svr = NULL; PUTBACK; FREETMPS; LEAVE; + if (svr && !SvTEMP(svr)) + sv_2mortal(svr); + if (chain) { vmg_dispell_guard_new(*chain); *chain = NULL; @@ -1855,7 +1867,7 @@ static void vmg_teardown(pTHX_ void *param) { vmg_sv_magicext((SV *) PL_strtab, NULL, &vmg_global_teardown_vtbl, NULL, 0); } } else { - assert(vmg_loaded > 1); + VMG_ASSERT(vmg_loaded > 1); --vmg_loaded; } @@ -1884,7 +1896,7 @@ static void vmg_setup(pTHX) { MUTEX_INIT(&vmg_op_name_init_mutex); vmg_loaded = 1; } else { - assert(vmg_loaded > 0); + VMG_ASSERT(vmg_loaded > 0); ++vmg_loaded; } @@ -2018,7 +2030,7 @@ PPCODE: MY_CXT.depth = old_depth; MY_CXT.freed_tokens = NULL; VMG_LOADED_LOCK; - assert(vmg_loaded > 0); + VMG_ASSERT(vmg_loaded > 0); ++vmg_loaded; VMG_LOADED_UNLOCK; }