You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2018/03/15 17:32:45 UTC

[arrow] branch master updated: ARROW-2316: [C++] Revert Buffer::mutable_data to inline so that linkers do not have to remember to define NDEBUG for release builds

This is an automated email from the ASF dual-hosted git repository.

wesm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 60749b2  ARROW-2316: [C++] Revert Buffer::mutable_data to inline so that linkers do not have to remember to define NDEBUG for release builds
60749b2 is described below

commit 60749b2d2b7c98559f985912936c535229f89093
Author: Wes McKinney <we...@twosigma.com>
AuthorDate: Thu Mar 15 13:32:38 2018 -0400

    ARROW-2316: [C++] Revert Buffer::mutable_data to inline so that linkers do not have to remember to define NDEBUG for release builds
    
    Author: Wes McKinney <we...@twosigma.com>
    
    Closes #1756 from wesm/revert-mutable-data-release-build and squashes the following commits:
    
    722273fe <Wes McKinney> clang-format
    ce1e7dd0 <Wes McKinney> Add debug-only mutability check to Buffer::mutable_data
    51098b48 <Wes McKinney> Revert Buffer::mutable_data to inline so that linkers do not have to remember to build with -DNDEBUG
---
 cpp/src/arrow/buffer.cc |  8 +-------
 cpp/src/arrow/buffer.h  | 12 ++++++++----
 2 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/cpp/src/arrow/buffer.cc b/cpp/src/arrow/buffer.cc
index e32e02c..60dd154 100644
--- a/cpp/src/arrow/buffer.cc
+++ b/cpp/src/arrow/buffer.cc
@@ -70,13 +70,7 @@ Status Buffer::FromString(const std::string& data, std::shared_ptr<Buffer>* out)
   return FromString(data, default_memory_pool(), out);
 }
 
-#ifndef NDEBUG
-// DCHECK macros aren't allowed in public include files
-uint8_t* Buffer::mutable_data() {
-  DCHECK(is_mutable());
-  return mutable_data_;
-}
-#endif
+void Buffer::CheckMutable() const { DCHECK(is_mutable()) << "buffer not mutable"; }
 
 PoolBuffer::PoolBuffer(MemoryPool* pool) : ResizableBuffer(nullptr, 0) {
   if (pool == nullptr) {
diff --git a/cpp/src/arrow/buffer.h b/cpp/src/arrow/buffer.h
index ad11ff9..06160d7 100644
--- a/cpp/src/arrow/buffer.h
+++ b/cpp/src/arrow/buffer.h
@@ -117,11 +117,13 @@ class ARROW_EXPORT Buffer {
 
   int64_t capacity() const { return capacity_; }
   const uint8_t* data() const { return data_; }
-#ifdef NDEBUG
-  uint8_t* mutable_data() { return mutable_data_; }
-#else
-  uint8_t* mutable_data();
+
+  uint8_t* mutable_data() {
+#ifndef NDEBUG
+    CheckMutable();
 #endif
+    return mutable_data_;
+  }
 
   int64_t size() const { return size_; }
 
@@ -137,6 +139,8 @@ class ARROW_EXPORT Buffer {
   // null by default, but may be set
   std::shared_ptr<Buffer> parent_;
 
+  void CheckMutable() const;
+
  private:
   ARROW_DISALLOW_COPY_AND_ASSIGN(Buffer);
 };

-- 
To stop receiving notification emails like this one, please contact
wesm@apache.org.