From 9ab859f5a5bfe414b887af3a692073e5351cdcc0 Mon Sep 17 00:00:00 2001 From: Ludger Sprenker Date: Wed, 24 Jan 2018 17:14:05 +0100 Subject: Create std::string in Arena memory --- src/google/protobuf/arenastring.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/google/protobuf/arenastring.h b/src/google/protobuf/arenastring.h index fb1b64a3..751c0f7a 100755 --- a/src/google/protobuf/arenastring.h +++ b/src/google/protobuf/arenastring.h @@ -322,10 +322,8 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr { void CreateInstance(::google::protobuf::Arena* arena, const ::std::string* initial_value) { GOOGLE_DCHECK(initial_value != NULL); - ptr_ = new ::std::string(*initial_value); - if (arena != NULL) { - arena->Own(ptr_); - } + // uses "new ::std::string" when arena is nullptr + ptr_ = Arena::Create<::std::string>(arena, *initial_value); } GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE void CreateInstanceNoArena(const ::std::string* initial_value) { -- cgit v1.2.3 From 14e8852fe483de57d155e7ba129d4c22f4e40279 Mon Sep 17 00:00:00 2001 From: Ludger Sprenker Date: Tue, 30 Jan 2018 18:14:49 +0100 Subject: Fix -fpermissive: '<::' cannot begin a template-argument list '<:' is an alternate spelling for '['. --- src/google/protobuf/arenastring.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/google/protobuf/arenastring.h b/src/google/protobuf/arenastring.h index 751c0f7a..2b108616 100755 --- a/src/google/protobuf/arenastring.h +++ b/src/google/protobuf/arenastring.h @@ -323,7 +323,7 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr { const ::std::string* initial_value) { GOOGLE_DCHECK(initial_value != NULL); // uses "new ::std::string" when arena is nullptr - ptr_ = Arena::Create<::std::string>(arena, *initial_value); + ptr_ = Arena::Create< ::std::string >(arena, *initial_value); } GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE void CreateInstanceNoArena(const ::std::string* initial_value) { -- cgit v1.2.3