From: Vincent Pit Date: Fri, 31 Jul 2015 18:48:51 +0000 (-0300) Subject: Make sure asserts are only checked on DEBUGGING builds X-Git-Tag: rt115392~5 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=6edfe5477c8d5f0fc681c7c317124380948f5300;p=perl%2Fmodules%2Findirect.git Make sure asserts are only checked on DEBUGGING builds --- diff --git a/indirect.xs b/indirect.xs index 3d901d0..ec53317 100644 --- a/indirect.xs +++ b/indirect.xs @@ -101,6 +101,12 @@ # 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; } }