Use GetArena() instead of GetOwningArena() #4.

PiperOrigin-RevId: 574544964
pull/14401/head
Protobuf Team Bot 1 year ago committed by Copybara-Service
parent 7f0787829f
commit eccbf14f11
  1. 2
      src/google/protobuf/arena.h
  2. 10
      src/google/protobuf/arena_unittest.cc

@ -261,7 +261,7 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final {
// again.
template <typename T>
PROTOBUF_ALWAYS_INLINE static void Destroy(T* obj) {
if (InternalGetOwningArena(obj) == nullptr) delete obj;
if (InternalGetArena(obj) == nullptr) delete obj;
}
// Allocates memory with the specific size and alignment.

@ -561,16 +561,6 @@ TEST(ArenaTest, UnsafeArenaSwap) {
TestUtil::ExpectAllFieldsSet(*message2);
}
TEST(ArenaTest, GetOwningArena) {
Arena arena;
auto* m1 = Arena::CreateMessage<TestAllTypes>(&arena);
EXPECT_EQ(Arena::InternalGetOwningArena(m1), &arena);
EXPECT_EQ(&arena, Arena::InternalGetOwningArena(
m1->mutable_repeated_foreign_message()));
EXPECT_EQ(&arena,
Arena::InternalGetOwningArena(m1->mutable_repeated_int32()));
}
TEST(ArenaTest, SwapBetweenArenasUsingReflection) {
Arena arena1;
TestAllTypes* arena1_message = Arena::CreateMessage<TestAllTypes>(&arena1);

Loading…
Cancel
Save