From 6215ccb587810e87d76513cd03bcbe81e87c28d4 Mon Sep 17 00:00:00 2001 From: yang-g Date: Fri, 17 May 2019 16:22:43 -0700 Subject: [PATCH] resolve comments --- include/grpcpp/impl/codegen/message_allocator.h | 7 ++++++- test/cpp/end2end/message_allocator_end2end_test.cc | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/grpcpp/impl/codegen/message_allocator.h b/include/grpcpp/impl/codegen/message_allocator.h index 422f8c2ea21..83544c64068 100644 --- a/include/grpcpp/impl/codegen/message_allocator.h +++ b/include/grpcpp/impl/codegen/message_allocator.h @@ -39,9 +39,14 @@ class RpcAllocatorState { template class MessageHolder : public RpcAllocatorState { public: - virtual void Release() { delete this; } + // Release this object. For example, if the custom allocator's + // AllocateMessasge creates an instance of a subclass with new, the Release() + // should do a "delete this;". + virtual void Release() = 0; RequestT* request() { return request_; } ResponseT* response() { return response_; } + + protected: void set_request(RequestT* request) { request_ = request; } void set_response(ResponseT* response) { response_ = response; } diff --git a/test/cpp/end2end/message_allocator_end2end_test.cc b/test/cpp/end2end/message_allocator_end2end_test.cc index 2abe26fe825..1c52259088a 100644 --- a/test/cpp/end2end/message_allocator_end2end_test.cc +++ b/test/cpp/end2end/message_allocator_end2end_test.cc @@ -346,6 +346,7 @@ class ArenaAllocatorTest : public MessageAllocatorEnd2endTestBase { set_response( google::protobuf::Arena::CreateMessage(&arena_)); } + void Release() override { delete this; } void FreeRequest() override { GPR_ASSERT(0); } private: