]> git.vpit.fr Git - perl/modules/re-engine-Plugin.git/blobdiff - Plugin.xs
Initialize all re::engine::Plugin members explicitely
[perl/modules/re-engine-Plugin.git] / Plugin.xs
index c16dfba3ed652bc61b82192036b858183fc49692..b06aec6365ed78bf08976da2b3fb6d4e28d3cb84 100644 (file)
--- a/Plugin.xs
+++ b/Plugin.xs
@@ -213,7 +213,7 @@ Plugin_comp(pTHX_ const SV * const pattern, const U32 flags)
 
  /* Our blessed object */
  obj = newSV(0);
- Newxz(re, 1, struct replug);
+ Newx(re, 1, struct replug);
  sv_setref_pv(obj, XSH_PACKAGE, (void *) re);
 
  newREGEXP(RX);
@@ -245,18 +245,17 @@ Plugin_comp(pTHX_ const SV * const pattern, const U32 flags)
  re->pattern  = (SV *) pattern;
  SvREFCNT_inc_simple_void(re->pattern);
 
- /* If there's an exec callback, store it into the private object so that it
-  * will be the one to be called, even if the engine changes in between */
- if (h->exec) {
-  re->cb_exec = h->exec;
-  SvREFCNT_inc_simple_void_NN(h->exec);
- }
+ re->str   = NULL;
+ re->stash = NULL;
 
- /* Same goes for the free callback, if there's one. */
- if (h->free) {
-  re->cb_free = h->free;
-  SvREFCNT_inc_simple_void_NN(h->free);
- }
+ /* Store the default exec callback (which may be NULL) into the regexp
+  * object. */
+ re->cb_exec = h->exec;
+ SvREFCNT_inc_simple_void(h->exec);
+
+ /* Same goes for the free callback. */
+ re->cb_free = h->free;
+ SvREFCNT_inc_simple_void(h->free);
 
  re->cb_num_capture_buff_FETCH  = NULL;
  re->cb_num_capture_buff_STORE  = NULL;
@@ -447,7 +446,7 @@ Plugin_numbered_buff_FETCH(pTHX_ REGEXP * const RX, const I32 paren,
 
   PUSHMARK(SP);
   XPUSHs(rx->pprivate);
-  XPUSHs(sv_2mortal(newSViv(paren)));
+  mXPUSHi(paren);
   PUTBACK;
 
   items = call_sv(callback, G_SCALAR);
@@ -490,7 +489,7 @@ Plugin_numbered_buff_STORE(pTHX_ REGEXP * const RX, const I32 paren,
 
   PUSHMARK(SP);
   XPUSHs(rx->pprivate);
-  XPUSHs(sv_2mortal(newSViv(paren)));
+  mXPUSHi(paren);
   XPUSHs((SV *) value);
   PUTBACK;
 
@@ -524,7 +523,7 @@ Plugin_numbered_buff_LENGTH(pTHX_ REGEXP * const RX, const SV * const sv,
 
   PUSHMARK(SP);
   XPUSHs(rx->pprivate);
-  XPUSHs(sv_2mortal(newSViv(paren)));
+  mXPUSHi(paren);
   PUTBACK;
 
   call_sv(callback, G_SCALAR);
@@ -654,13 +653,11 @@ PPCODE:
  if (items > 1) {
   self->rx->minlen = (I32)SvIV(ST(1));
   XSRETURN_EMPTY;
- } else {
-  if (self->rx->minlen) {
-   XPUSHs(sv_2mortal(newSViv(self->rx->minlen)));
-  } else {
-   XPUSHs(sv_2mortal(&PL_sv_undef));
-  }
+ } else if (self->rx->minlen) {
+  mXPUSHi(self->rx->minlen);
   XSRETURN(1);
+ } else {
+  XSRETURN_UNDEF;
  }
 
 void
@@ -669,13 +666,11 @@ PPCODE:
  if (items > 1) {
   self->rx->gofs = (U32)SvIV(ST(1));
   XSRETURN_EMPTY;
- } else {
-  if (self->rx->gofs) {
-   XPUSHs(sv_2mortal(newSVuv(self->rx->gofs)));
-  } else {
-   XPUSHs(sv_2mortal(&PL_sv_undef));
-  }
+ } else if (self->rx->gofs) {
+  mXPUSHu(self->rx->gofs);
   XSRETURN(1);
+ } else {
+  XSRETURN_UNDEF;
  }
 
 void
@@ -684,13 +679,11 @@ PPCODE:
  if (items > 1) {
   self->rx->nparens = (U32)SvIV(ST(1));
   XSRETURN_EMPTY;
- } else {
-  if (self->rx->nparens) {
-   XPUSHs(sv_2mortal(newSVuv(self->rx->nparens)));
-  } else {
-   XPUSHs(sv_2mortal(&PL_sv_undef));
-  }
+ } else if (self->rx->nparens) {
+  mXPUSHu(self->rx->nparens);
   XSRETURN(1);
+ } else {
+  XSRETURN_UNDEF;
  }
 
 void
@@ -758,5 +751,5 @@ OUTPUT:
 void
 ENGINE()
 PPCODE:
XPUSHs(sv_2mortal(newSViv(PTR2IV(&engine_plugin))));
mXPUSHi(PTR2IV(&engine_plugin));
  XSRETURN(1);