Index: third_party/protobuf/src/google/protobuf/arena.h |
diff --git a/third_party/protobuf/src/google/protobuf/arena.h b/third_party/protobuf/src/google/protobuf/arena.h |
index 870665076fb8929968719201da61431a0e7d903d..cf07b9fc97c0cf4b7f7f4dba9caa5a9edc963833 100644 |
--- a/third_party/protobuf/src/google/protobuf/arena.h |
+++ b/third_party/protobuf/src/google/protobuf/arena.h |
@@ -28,8 +28,6 @@ |
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
-// This file defines an Arena allocator for better allocation performance. |
- |
#ifndef GOOGLE_PROTOBUF_ARENA_H__ |
#define GOOGLE_PROTOBUF_ARENA_H__ |
@@ -79,13 +77,8 @@ template<typename T> void arena_destruct_object(void* object) { |
template<typename T> void arena_delete_object(void* object) { |
delete reinterpret_cast<T*>(object); |
} |
-inline void arena_free(void* object, size_t size) { |
-#if defined(__GXX_DELETE_WITH_SIZE__) || defined(__cpp_sized_deallocation) |
- ::operator delete(object, size); |
-#else |
- (void)size; |
- ::operator delete(object); |
-#endif |
+inline void arena_free(void* object, size_t /* size */) { |
+ free(object); |
} |
} // namespace internal |
@@ -149,7 +142,7 @@ struct ArenaOptions { |
max_block_size(kDefaultMaxBlockSize), |
initial_block(NULL), |
initial_block_size(0), |
- block_alloc(&::operator new), |
+ block_alloc(&malloc), |
block_dealloc(&internal::arena_free), |
on_arena_init(NULL), |
on_arena_reset(NULL), |
@@ -218,10 +211,12 @@ struct ArenaOptions { |
// |
// This protocol is implemented by all arena-enabled proto2 message classes as |
// well as RepeatedPtrField. |
-// |
-// Do NOT subclass Arena. This class will be marked as final when C++11 is |
-// enabled. |
+ |
+#if __cplusplus >= 201103L |
+class LIBPROTOBUF_EXPORT Arena final { |
+#else |
class LIBPROTOBUF_EXPORT Arena { |
+#endif |
public: |
// Arena constructor taking custom options. See ArenaOptions below for |
// descriptions of the options available. |
@@ -459,7 +454,7 @@ class LIBPROTOBUF_EXPORT Arena { |
// Combines SpaceAllocated and SpaceUsed. Returns a pair of |
// <space_allocated, space_used>. |
- GOOGLE_ATTRIBUTE_NOINLINE std::pair<uint64, uint64> SpaceAllocatedAndUsed() const; |
+ GOOGLE_ATTRIBUTE_NOINLINE pair<uint64, uint64> SpaceAllocatedAndUsed() const; |
// Frees all storage allocated by this arena after calling destructors |
// registered with OwnDestructor() and freeing objects registered with Own(). |
@@ -613,7 +608,6 @@ class LIBPROTOBUF_EXPORT Arena { |
const T>(static_cast<const T*>(0))) == sizeof(char) || |
google::protobuf::internal::has_trivial_destructor<T>::value> {}; |
- private: |
// CreateMessage<T> requires that T supports arenas, but this private method |
// works whether or not T supports arenas. These are not exposed to user code |
// as it can cause confusing API usages, and end up having double free in |
@@ -807,7 +801,7 @@ class LIBPROTOBUF_EXPORT Arena { |
template <typename T> |
static void CreateInArenaStorageInternal( |
T* ptr, Arena* arena, google::protobuf::internal::false_type) { |
- new (ptr) T(); |
+ new (ptr) T; |
} |
template <typename T> |