]> git.vpit.fr Git - perl/modules/indirect.git/commitdiff
Make sure asserts are only checked on DEBUGGING builds
authorVincent Pit <vince@profvince.com>
Fri, 31 Jul 2015 18:48:51 +0000 (15:48 -0300)
committerVincent Pit <vince@profvince.com>
Fri, 31 Jul 2015 18:48:51 +0000 (15:48 -0300)
indirect.xs

index 3d901d0f7d457d9e0af25a5816c4b4b977abe146..ec533170104b8d1479aa1f7e894701d3cc92d911 100644 (file)
 # endif
 #endif
 
+#ifdef DEBUGGING
+# define I_ASSERT(C) assert(C)
+#else
+# define I_ASSERT(C)
+#endif
+
 #ifndef I_WORKAROUND_REQUIRE_PROPAGATION
 # define I_WORKAROUND_REQUIRE_PROPAGATION !I_HAS_PERL(5, 10, 1)
 #endif
@@ -247,13 +253,13 @@ static int indirect_set_loaded_locked(pTHX_ void *cxt) {
  int global_setup = 0;
 
  if (indirect_loaded <= 0) {
-  assert(indirect_loaded == 0);
-  assert(!indirect_loaded_cxts);
+  I_ASSERT(indirect_loaded == 0);
+  I_ASSERT(!indirect_loaded_cxts);
   indirect_loaded_cxts = ptable_new();
   global_setup         = 1;
  }
  ++indirect_loaded;
assert(indirect_loaded_cxts);
I_ASSERT(indirect_loaded_cxts);
  ptable_loaded_store(indirect_loaded_cxts, cxt, cxt);
 
  return global_setup;
@@ -264,11 +270,11 @@ static int indirect_clear_loaded_locked(pTHX_ void *cxt) {
  int global_teardown = 0;
 
  if (indirect_loaded > 1) {
-  assert(indirect_loaded_cxts);
+  I_ASSERT(indirect_loaded_cxts);
   ptable_loaded_delete(indirect_loaded_cxts, cxt);
   --indirect_loaded;
  } else if (indirect_loaded_cxts) {
-  assert(indirect_loaded == 1);
+  I_ASSERT(indirect_loaded == 1);
   ptable_loaded_free(indirect_loaded_cxts);
   indirect_loaded_cxts = NULL;
   indirect_loaded      = 0;
@@ -1190,7 +1196,7 @@ PPCODE:
    int global_setup;
    I_LOADED_LOCK;
    global_setup = indirect_set_loaded_locked(&MY_CXT);
-   assert(!global_setup);
+   I_ASSERT(!global_setup);
    I_LOADED_UNLOCK;
   }
  }