From d21141b5df3a700c446c6bf089f36f4b6df20568 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Thu, 14 May 2020 20:35:22 -0700 Subject: [PATCH] Let's play with new[] --- src/core/lib/channel/handshaker_registry.cc | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/core/lib/channel/handshaker_registry.cc b/src/core/lib/channel/handshaker_registry.cc index 0e686af8992..c2a837396f2 100644 --- a/src/core/lib/channel/handshaker_registry.cc +++ b/src/core/lib/channel/handshaker_registry.cc @@ -76,25 +76,12 @@ void HandshakerFactoryList::AddHandshakers(const grpc_channel_args* args, void HandshakerRegistry::Init() { GPR_ASSERT(g_handshaker_factory_lists == nullptr); - g_handshaker_factory_lists = - static_cast(gpr_malloc_aligned( - sizeof(*g_handshaker_factory_lists) * NUM_HANDSHAKER_TYPES, - GPR_MAX_ALIGNMENT)); - - GPR_ASSERT(g_handshaker_factory_lists != nullptr); - for (auto idx = 0; idx < NUM_HANDSHAKER_TYPES; ++idx) { - auto factory_list = g_handshaker_factory_lists + idx; - new (factory_list) HandshakerFactoryList(); - } + g_handshaker_factory_lists = new HandshakerFactoryList[NUM_HANDSHAKER_TYPES]; } void HandshakerRegistry::Shutdown() { GPR_ASSERT(g_handshaker_factory_lists != nullptr); - for (auto idx = 0; idx < NUM_HANDSHAKER_TYPES; ++idx) { - auto factory_list = g_handshaker_factory_lists + idx; - factory_list->~HandshakerFactoryList(); - } - gpr_free_aligned(g_handshaker_factory_lists); + delete[] g_handshaker_factory_lists; g_handshaker_factory_lists = nullptr; }