From afa49931ae90cc375cf1970bfa8b764c2c6a3900 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 16 Aug 2018 16:52:26 +0800 Subject: [PATCH] cpp-btree: do not #define NDEBUG use no_debug instead, the NDEBUG macro pollutes all source files including this header. Signed-off-by: Kefu Chai --- src/include/cpp-btree/btree.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/include/cpp-btree/btree.h b/src/include/cpp-btree/btree.h index 49310a2e441d3..48635159dc0ba 100644 --- a/src/include/cpp-btree/btree.h +++ b/src/include/cpp-btree/btree.h @@ -115,10 +115,6 @@ #include #include -#ifndef NDEBUG -#define NDEBUG 1 -#endif - namespace btree { // Inside a btree method, if we just call swap(), it will choose the @@ -681,6 +677,11 @@ class btree_node { // Swap the contents of "this" and "src". void swap(btree_node *src); +#ifdef NDEBUG + static constexpr auto no_debug = true; +#else + static constexpr auto no_debug = false; +#endif // Node allocation/deletion routines. static btree_node* init_leaf( leaf_fields *f, btree_node *parent, int max_count) { @@ -690,7 +691,7 @@ class btree_node { f->max_count = max_count; f->count = 0; f->parent = parent; - if (!NDEBUG) { + if (!no_debug) { memset(&f->values, 0, max_count * sizeof(value_type)); } return n; @@ -698,7 +699,7 @@ class btree_node { static btree_node* init_internal(internal_fields *f, btree_node *parent) { btree_node *n = init_leaf(f, parent, kNodeValues); f->leaf = 0; - if (!NDEBUG) { + if (!no_debug) { memset(f->children, 0, sizeof(f->children)); } return n; -- 2.39.5