]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cpp-btree: do not #define NDEBUG 23591/head
authorKefu Chai <kchai@redhat.com>
Thu, 16 Aug 2018 08:52:26 +0000 (16:52 +0800)
committerKefu Chai <kchai@redhat.com>
Sun, 19 Aug 2018 08:42:40 +0000 (16:42 +0800)
use no_debug instead, the NDEBUG macro pollutes all source files
including this header.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/include/cpp-btree/btree.h

index 49310a2e441d34391fdf9f4277051fe02baaccb9..48635159dc0baa8d9cd78b777311ea54175e49c0 100644 (file)
 #include <string>
 #include <utility>
 
-#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;