X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=Plugin.xs;h=7c01ad5364e2a63d7ba09d5c11446824ce6412df;hb=c2d7bc787853308707a3baf0e28f8c2d952a7936;hp=d64951ea73016f3fcdc3a5dec3d0404c43246b0a;hpb=1780282616fa174a9ebad39f0ecf797ebc9a3cb8;p=perl%2Fmodules%2Fre-engine-Plugin.git diff --git a/Plugin.xs b/Plugin.xs index d64951e..7c01ad5 100644 --- a/Plugin.xs +++ b/Plugin.xs @@ -150,21 +150,12 @@ STATIC void rep_ptable_clone(pTHX_ ptable_ent *ent, void *ud_) { ptable_store(ud->tbl, ent->key, h2); } -STATIC void rep_thread_cleanup(pTHX_ void *); +#include "reap.h" STATIC void rep_thread_cleanup(pTHX_ void *ud) { - int *level = ud; - - if (*level) { - *level = 0; - LEAVE; - SAVEDESTRUCTOR_X(rep_thread_cleanup, level); - ENTER; - } else { - dMY_CXT; - PerlMemShared_free(level); - ptable_free(MY_CXT.tbl); - } + dMY_CXT; + + ptable_free(MY_CXT.tbl); } #endif /* REP_THREADSAFE */ @@ -249,12 +240,17 @@ STATIC const rep_hint_t *rep_hint(pTHX) { #define rep_hint() rep_hint(aTHX) SV *hint; +#ifdef cop_hints_fetch_pvn + hint = cop_hints_fetch_pvn(PL_curcop, + __PACKAGE__, __PACKAGE_LEN__, rep_hash, 0); +#else /* We already require 5.9.5 for the regexp engine API. */ hint = Perl_refcounted_he_fetch(aTHX_ PL_curcop->cop_hints_hash, NULL, __PACKAGE__, __PACKAGE_LEN__, 0, rep_hash); +#endif return rep_detag(hint); } @@ -322,7 +318,7 @@ Plugin_comp(pTHX_ SV * const pattern, U32 flags) * in between */ if (h->exec) { re->cb_exec = h->exec; - SvREFCNT_inc_simple_void_NN(h->exec); + SvREFCNT_inc_simple_void_NN(h->exec); } re->cb_num_capture_buff_FETCH = NULL; @@ -638,7 +634,7 @@ STATIC U32 rep_booted = 0; /* --- XS ------------------------------------------------------------------ */ -MODULE = re::engine::Plugin PACKAGE = re::engine::Plugin +MODULE = re::engine::Plugin PACKAGE = re::engine::Plugin PROTOTYPES: DISABLE @@ -657,29 +653,23 @@ void CLONE(...) PREINIT: ptable *t; - int *level; -CODE: - { - my_cxt_t ud; - dMY_CXT; - ud.tbl = t = ptable_new(); - ud.owner = MY_CXT.owner; - ptable_walk(MY_CXT.tbl, rep_ptable_clone, &ud); - } +PPCODE: { - MY_CXT_CLONE; - MY_CXT.tbl = t; - MY_CXT.owner = aTHX; + my_cxt_t ud; + dMY_CXT; + ud.tbl = t = ptable_new(); + ud.owner = MY_CXT.owner; + ptable_walk(MY_CXT.tbl, rep_ptable_clone, &ud); } { - level = PerlMemShared_malloc(sizeof *level); - *level = 1; - LEAVEn("sub"); - SAVEDESTRUCTOR_X(rep_thread_cleanup, level); - ENTERn("sub"); + MY_CXT_CLONE; + MY_CXT.tbl = t; + MY_CXT.owner = aTHX; } + reap(3, rep_thread_cleanup, NULL); + XSRETURN(0); -#endif +#endif /* REP_THREADSAFE */ void pattern(re::engine::Plugin self, ...)