aboutsummaryrefslogtreecommitdiff
path: root/src/google/protobuf/arena.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/google/protobuf/arena.cc')
-rwxr-xr-xsrc/google/protobuf/arena.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/google/protobuf/arena.cc b/src/google/protobuf/arena.cc
index cd0b21a7..613e5897 100755
--- a/src/google/protobuf/arena.cc
+++ b/src/google/protobuf/arena.cc
@@ -30,6 +30,7 @@
#include <google/protobuf/arena.h>
+
#ifdef ADDRESS_SANITIZER
#include <sanitizer/asan_interface.h>
#endif
@@ -37,6 +38,7 @@
namespace google {
namespace protobuf {
+
google::protobuf::internal::SequenceNumber Arena::lifecycle_id_generator_;
#if defined(GOOGLE_PROTOBUF_NO_THREADLOCAL)
Arena::ThreadCache& Arena::thread_cache() {
@@ -247,6 +249,19 @@ uint64 Arena::SpaceUsed() const {
return space_used;
}
+pair<uint64, uint64> Arena::SpaceAllocatedAndUsed() const {
+ uint64 allocated = 0;
+ uint64 used = 0;
+
+ Block* b = reinterpret_cast<Block*>(google::protobuf::internal::NoBarrier_Load(&blocks_));
+ while (b != NULL) {
+ allocated += b->size;
+ used += (b->pos - kHeaderSize);
+ b = b->next;
+ }
+ return std::make_pair(allocated, used);
+}
+
uint64 Arena::FreeBlocks() {
uint64 space_allocated = 0;
Block* b = reinterpret_cast<Block*>(google::protobuf::internal::NoBarrier_Load(&blocks_));