]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blobdiff - Magic.xs
Use SvREFCNT_inc_simple_void() whenever possible
[perl/modules/Variable-Magic.git] / Magic.xs
index 120287f14cc4f8bfe9c5ea3ec210382ff5f950de..cc403646a401293a8f473da988ab4f6453ee2229 100644 (file)
--- a/Magic.xs
+++ b/Magic.xs
@@ -100,6 +100,14 @@ STATIC SV *vmg_clone(pTHX_ SV *sv, tTHX owner) {
 # define SvMAGIC_set(sv, val) (SvMAGIC(sv) = (val))
 #endif
 
+#ifndef SvRV_const
+# define SvRV_const(sv) SvRV((SV *) sv)
+#endif
+
+#ifndef SvREFCNT_inc_simple_void
+# define SvREFCNT_inc_simple_void(sv) SvREFCNT_inc(sv)
+#endif
+
 #ifndef mPUSHu
 # define mPUSHu(U) PUSHs(sv_2mortal(newSVuv(U)))
 #endif
@@ -526,7 +534,7 @@ STATIC SV *vmg_wizard_new(pTHX_ const MGWIZ *w) {
 STATIC const SV *vmg_wizard_validate(pTHX_ const SV *wiz) {
 #define vmg_wizard_validate(W) vmg_wizard_validate(aTHX_ (W))
  if (SvROK(wiz)) {
-  wiz = SvRV(wiz);
+  wiz = SvRV_const(wiz);
   if (SvIOK(wiz))
    return wiz;
  }
@@ -629,9 +637,9 @@ STATIC SV *vmg_data_new(pTHX_ SV *ctor, SV *sv, SV **args, I32 items) {
  SPAGAIN;
  nsv = POPs;
 #if VMG_HAS_PERL(5, 8, 3)
- SvREFCNT_inc(nsv);    /* Or it will be destroyed in FREETMPS */
+ SvREFCNT_inc_simple_void(nsv); /* Or it will be destroyed in FREETMPS */
 #else
- nsv = sv_newref(nsv); /* Workaround some bug in SvREFCNT_inc() */
+ nsv = sv_newref(nsv);          /* Workaround some bug in SvREFCNT_inc() */
 #endif
  PUTBACK;
 
@@ -1048,7 +1056,7 @@ STATIC int vmg_svt_free(pTHX_ SV *sv, MAGIC *mg) {
  w = vmg_wizard_mgwiz(mg->mg_ptr);
 
  /* So that it survives the temp cleanup below */
- SvREFCNT_inc(sv);
+ SvREFCNT_inc_simple_void(sv);
 
 #if !VMG_HAS_PERL_MAINT(5, 11, 0, 32686)
  /* The previous magic tokens were freed but the magic chain wasn't updated, so