From 3a519a0b64038073540c83722256ba57c20e728d Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Wed, 6 Nov 2019 13:30:09 -0800 Subject: [PATCH] Replaced grpc_core New & Delete with C++ new & delete --- CMakeLists.txt | 38 -------- Makefile | 48 ---------- build.yaml | 12 --- .../filters/client_channel/client_channel.cc | 28 +++--- .../client_channel/global_subchannel_pool.cc | 10 +- .../health/health_check_client.cc | 2 +- .../client_channel/lb_policy/grpclb/grpclb.cc | 6 +- .../lb_policy/grpclb/grpclb_client_stats.cc | 2 +- .../lb_policy/pick_first/pick_first.cc | 2 +- .../lb_policy/round_robin/round_robin.cc | 2 +- .../lb_policy/subchannel_list.h | 6 +- .../client_channel/lb_policy/xds/xds.cc | 6 +- .../client_channel/lb_policy_registry.cc | 4 +- .../client_channel/local_subchannel_pool.cc | 6 +- .../dns/c_ares/grpc_ares_ev_driver.cc | 6 +- .../dns/c_ares/grpc_ares_ev_driver_libuv.cc | 8 +- .../dns/c_ares/grpc_ares_ev_driver_posix.cc | 2 +- .../dns/c_ares/grpc_ares_ev_driver_windows.cc | 10 +- .../resolver/dns/c_ares/grpc_ares_wrapper.cc | 4 +- .../resolver/fake/fake_resolver.cc | 18 ++-- .../client_channel/resolver_registry.cc | 4 +- .../client_channel/resolving_lb_policy.cc | 2 +- .../filters/client_channel/service_config.cc | 4 +- .../filters/client_channel/service_config.h | 13 +-- .../ext/filters/client_channel/subchannel.cc | 12 +-- .../filters/client_channel/xds/xds_client.cc | 10 +- .../ext/filters/deadline/deadline_filter.cc | 4 +- .../ext/filters/max_age/max_age_filter.cc | 3 +- .../chttp2/client/insecure/channel_create.cc | 2 +- .../client/secure/secure_channel_create.cc | 2 +- .../chttp2/transport/chttp2_transport.cc | 4 +- .../chttp2/transport/context_list.cc | 4 +- .../transport/chttp2/transport/frame_data.cc | 2 +- .../ext/transport/chttp2/transport/internal.h | 6 +- .../cronet/transport/cronet_transport.cc | 6 +- src/core/lib/channel/channel_trace.cc | 8 +- src/core/lib/channel/channelz_registry.cc | 4 +- src/core/lib/gprpp/fork.cc | 8 +- src/core/lib/gprpp/memory.h | 35 +------ src/core/lib/gprpp/orphanable.h | 6 +- src/core/lib/gprpp/ref_counted.h | 6 +- src/core/lib/gprpp/ref_counted_ptr.h | 2 +- src/core/lib/gprpp/thd.h | 2 +- src/core/lib/gprpp/thd_posix.cc | 6 +- src/core/lib/gprpp/thd_windows.cc | 6 +- .../lib/http/httpcli_security_connector.cc | 4 +- src/core/lib/iomgr/buffer_list.cc | 6 +- src/core/lib/iomgr/cfstream_handle.cc | 4 +- src/core/lib/iomgr/combiner.cc | 4 +- src/core/lib/iomgr/executor.cc | 12 +-- src/core/lib/iomgr/executor/threadpool.cc | 8 +- src/core/lib/iomgr/resolve_address_custom.cc | 2 +- src/core/lib/iomgr/tcp_server_posix.cc | 4 +- src/core/lib/iomgr/udp_server.cc | 4 +- .../credentials/alts/alts_credentials.cc | 5 +- .../composite/composite_credentials.cc | 8 +- .../lib/security/credentials/credentials.cc | 10 +- .../lib/security/credentials/credentials.h | 4 +- .../credentials/fake/fake_credentials.cc | 7 +- .../credentials/local/local_credentials.cc | 4 +- .../credentials/oauth2/oauth2_credentials.cc | 2 +- .../credentials/plugin/plugin_credentials.cc | 2 +- .../credentials/ssl/ssl_credentials.cc | 8 +- .../tls/grpc_tls_credentials_options.cc | 10 +- .../credentials/tls/spiffe_credentials.cc | 4 +- .../tls/spiffe_security_connector.cc | 9 +- .../lib/security/transport/secure_endpoint.cc | 8 +- src/core/lib/slice/slice.cc | 21 ++-- src/core/lib/surface/server.cc | 3 +- src/core/lib/transport/connectivity_state.cc | 4 +- src/core/lib/transport/metadata.cc | 18 ++-- src/core/lib/transport/metadata.h | 6 +- src/core/lib/transport/static_metadata.cc | 6 +- src/core/lib/transport/transport.cc | 4 +- .../alts/handshaker/alts_tsi_handshaker.cc | 4 +- .../ssl/session_cache/ssl_session_cache.cc | 6 +- .../CronetTests/CoreCronetEnd2EndTests.mm | 2 +- .../dns_resolver_connectivity_test.cc | 2 +- .../resolvers/dns_resolver_cooldown_test.cc | 7 +- .../resolvers/fake_resolver_test.cc | 2 +- test/core/end2end/bad_server_response_test.cc | 4 +- test/core/end2end/fixtures/h2_census.cc | 4 +- test/core/end2end/fixtures/h2_compress.cc | 4 +- test/core/end2end/fixtures/h2_fakesec.cc | 5 +- test/core/end2end/fixtures/h2_full+pipe.cc | 4 +- test/core/end2end/fixtures/h2_full+trace.cc | 4 +- .../end2end/fixtures/h2_full+workarounds.cc | 4 +- test/core/end2end/fixtures/h2_full.cc | 4 +- test/core/end2end/fixtures/h2_http_proxy.cc | 4 +- test/core/end2end/fixtures/h2_oauth2.cc | 5 +- test/core/end2end/fixtures/h2_spiffe.cc | 5 +- test/core/end2end/fixtures/h2_ssl.cc | 5 +- .../end2end/fixtures/h2_ssl_cred_reload.cc | 5 +- .../end2end/fixtures/http_proxy_fixture.cc | 4 +- test/core/end2end/fixtures/local_util.cc | 4 +- test/core/end2end/fixtures/proxy.cc | 4 +- test/core/end2end/fuzzers/api_fuzzer.cc | 4 +- test/core/end2end/h2_ssl_cert_test.cc | 5 +- test/core/end2end/inproc_callback_test.cc | 8 +- test/core/gprpp/BUILD | 14 --- test/core/gprpp/inlined_vector_test.cc | 2 +- test/core/gprpp/memory_test.cc | 95 ------------------- test/core/gprpp/mpscq_test.cc | 2 +- test/core/gprpp/orphanable_test.cc | 6 +- test/core/gprpp/ref_counted_ptr_test.cc | 38 ++++---- test/core/gprpp/ref_counted_test.cc | 12 +-- test/core/iomgr/mpmcqueue_test.cc | 30 +++--- test/core/iomgr/threadpool_test.cc | 42 ++++---- test/core/iomgr/udp_server_test.cc | 4 +- test/core/security/credentials_test.cc | 5 +- test/core/surface/completion_queue_test.cc | 4 +- .../core/transport/connectivity_state_test.cc | 6 +- test/core/util/test_lb_policies.cc | 6 +- test/cpp/client/credentials_test.cc | 15 ++- test/cpp/microbenchmarks/bm_chttp2_hpack.cc | 2 +- test/cpp/microbenchmarks/bm_threadpool.cc | 4 +- test/cpp/naming/cancel_ares_query_test.cc | 2 +- test/cpp/naming/resolver_component_test.cc | 6 +- tools/codegen/core/gen_static_metadata.py | 5 +- tools/run_tests/generated/tests.json | 24 ----- 120 files changed, 353 insertions(+), 652 deletions(-) delete mode 100644 test/core/gprpp/memory_test.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b8fe560e75..d6da566a87a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -748,7 +748,6 @@ if(gRPC_BUILD_TESTS) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_cxx json_run_localhost) endif() - add_dependencies(buildtests_cxx memory_test) add_dependencies(buildtests_cxx message_allocator_end2end_test) add_dependencies(buildtests_cxx metrics_client) add_dependencies(buildtests_cxx mock_test) @@ -13501,43 +13500,6 @@ endif() endif() if(gRPC_BUILD_TESTS) -add_executable(memory_test - test/core/gprpp/memory_test.cc - third_party/googletest/googletest/src/gtest-all.cc - third_party/googletest/googlemock/src/gmock-all.cc -) - -target_include_directories(memory_test - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} - ${_gRPC_SSL_INCLUDE_DIR} - ${_gRPC_UPB_GENERATED_DIR} - ${_gRPC_UPB_GRPC_GENERATED_DIR} - ${_gRPC_UPB_INCLUDE_DIR} - ${_gRPC_ZLIB_INCLUDE_DIR} - third_party/googletest/googletest/include - third_party/googletest/googletest - third_party/googletest/googlemock/include - third_party/googletest/googlemock - ${_gRPC_PROTO_GENS_DIR} -) - -target_link_libraries(memory_test - ${_gRPC_PROTOBUF_LIBRARIES} - ${_gRPC_ALLTARGETS_LIBRARIES} - grpc_test_util - grpc++ - grpc - gpr - ${_gRPC_GFLAGS_LIBRARIES} -) - - -endif() -if(gRPC_BUILD_TESTS) - add_executable(message_allocator_end2end_test test/cpp/end2end/message_allocator_end2end_test.cc third_party/googletest/googletest/src/gtest-all.cc diff --git a/Makefile b/Makefile index 9f5a4c68e2b..b4e3fc05012 100644 --- a/Makefile +++ b/Makefile @@ -1256,7 +1256,6 @@ interop_client: $(BINDIR)/$(CONFIG)/interop_client interop_server: $(BINDIR)/$(CONFIG)/interop_server interop_test: $(BINDIR)/$(CONFIG)/interop_test json_run_localhost: $(BINDIR)/$(CONFIG)/json_run_localhost -memory_test: $(BINDIR)/$(CONFIG)/memory_test message_allocator_end2end_test: $(BINDIR)/$(CONFIG)/message_allocator_end2end_test metrics_client: $(BINDIR)/$(CONFIG)/metrics_client mock_test: $(BINDIR)/$(CONFIG)/mock_test @@ -1726,7 +1725,6 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/interop_server \ $(BINDIR)/$(CONFIG)/interop_test \ $(BINDIR)/$(CONFIG)/json_run_localhost \ - $(BINDIR)/$(CONFIG)/memory_test \ $(BINDIR)/$(CONFIG)/message_allocator_end2end_test \ $(BINDIR)/$(CONFIG)/metrics_client \ $(BINDIR)/$(CONFIG)/mock_test \ @@ -1898,7 +1896,6 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/interop_server \ $(BINDIR)/$(CONFIG)/interop_test \ $(BINDIR)/$(CONFIG)/json_run_localhost \ - $(BINDIR)/$(CONFIG)/memory_test \ $(BINDIR)/$(CONFIG)/message_allocator_end2end_test \ $(BINDIR)/$(CONFIG)/metrics_client \ $(BINDIR)/$(CONFIG)/mock_test \ @@ -2410,8 +2407,6 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/inproc_sync_unary_ping_pong_test || ( echo test inproc_sync_unary_ping_pong_test failed ; exit 1 ) $(E) "[RUN] Testing interop_test" $(Q) $(BINDIR)/$(CONFIG)/interop_test || ( echo test interop_test failed ; exit 1 ) - $(E) "[RUN] Testing memory_test" - $(Q) $(BINDIR)/$(CONFIG)/memory_test || ( echo test memory_test failed ; exit 1 ) $(E) "[RUN] Testing message_allocator_end2end_test" $(Q) $(BINDIR)/$(CONFIG)/message_allocator_end2end_test || ( echo test message_allocator_end2end_test failed ; exit 1 ) $(E) "[RUN] Testing mock_test" @@ -17811,49 +17806,6 @@ endif endif -MEMORY_TEST_SRC = \ - test/core/gprpp/memory_test.cc \ - -MEMORY_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(MEMORY_TEST_SRC)))) -ifeq ($(NO_SECURE),true) - -# You can't build secure targets if you don't have OpenSSL. - -$(BINDIR)/$(CONFIG)/memory_test: openssl_dep_error - -else - - - - -ifeq ($(NO_PROTOBUF),true) - -# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+. - -$(BINDIR)/$(CONFIG)/memory_test: protobuf_dep_error - -else - -$(BINDIR)/$(CONFIG)/memory_test: $(PROTOBUF_DEP) $(MEMORY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a - $(E) "[LD] Linking $@" - $(Q) mkdir -p `dirname $@` - $(Q) $(LDXX) $(LDFLAGS) $(MEMORY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/memory_test - -endif - -endif - -$(OBJDIR)/$(CONFIG)/test/core/gprpp/memory_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a - -deps_memory_test: $(MEMORY_TEST_OBJS:.o=.dep) - -ifneq ($(NO_SECURE),true) -ifneq ($(NO_DEPS),true) --include $(MEMORY_TEST_OBJS:.o=.dep) -endif -endif - - MESSAGE_ALLOCATOR_END2END_TEST_SRC = \ test/cpp/end2end/message_allocator_end2end_test.cc \ diff --git a/build.yaml b/build.yaml index 5a6b6c6398c..229d222b820 100644 --- a/build.yaml +++ b/build.yaml @@ -5347,18 +5347,6 @@ targets: - mac - linux - posix -- name: memory_test - gtest: true - build: test - language: c++ - src: - - test/core/gprpp/memory_test.cc - deps: - - grpc_test_util - - grpc++ - - grpc - - gpr - uses_polling: false - name: message_allocator_end2end_test gtest: true cpu_cost: 0.5 diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index ada3f8bb4f7..a3e46ca0825 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -162,7 +162,7 @@ class ChannelData { MutexLock lock(&external_watchers_mu_); // Will be deleted when the watch is complete. GPR_ASSERT(external_watchers_[on_complete] == nullptr); - external_watchers_[on_complete] = New( + external_watchers_[on_complete] = new ExternalConnectivityWatcher( this, pollent, state, on_complete, watcher_timer_init); } @@ -901,9 +901,9 @@ class ChannelData::SubchannelWrapper : public SubchannelInterface { UniquePtr watcher) override { auto& watcher_wrapper = watcher_map_[watcher.get()]; GPR_ASSERT(watcher_wrapper == nullptr); - watcher_wrapper = New(std::move(watcher), - Ref(DEBUG_LOCATION, "WatcherWrapper"), - initial_state); + watcher_wrapper = new WatcherWrapper(std::move(watcher), + Ref(DEBUG_LOCATION, "WatcherWrapper"), + initial_state); subchannel_->WatchConnectivityState( initial_state, UniquePtr(gpr_strdup(health_check_service_name_.get())), @@ -1018,7 +1018,7 @@ class ChannelData::SubchannelWrapper : public SubchannelInterface { connected_subchannel.get(), ConnectivityStateName(new_state)); } // Will delete itself. - New(Ref(), new_state, std::move(connected_subchannel)); + new Updater(Ref(), new_state, std::move(connected_subchannel)); } grpc_pollset_set* interested_parties() override { @@ -1030,7 +1030,7 @@ class ChannelData::SubchannelWrapper : public SubchannelInterface { WatcherWrapper* MakeReplacement() { auto* replacement = - New(std::move(watcher_), parent_, last_seen_state_); + new WatcherWrapper(std::move(watcher_), parent_, last_seen_state_); replacement_ = replacement; return replacement; } @@ -1074,7 +1074,7 @@ class ChannelData::SubchannelWrapper : public SubchannelInterface { self->parent_->parent_->MaybeUpdateConnectedSubchannel( std::move(self->connected_subchannel_)); self->parent_->watcher_->OnConnectivityStateChange(self->state_); - Delete(self); + delete self; } RefCountedPtr parent_; @@ -1237,7 +1237,7 @@ class ChannelData::ConnectivityWatcherAdder { std::move(self->watcher_)); GRPC_CHANNEL_STACK_UNREF(self->chand_->owning_stack_, "ConnectivityWatcherAdder"); - Delete(self); + delete self; } ChannelData* chand_; @@ -1270,7 +1270,7 @@ class ChannelData::ConnectivityWatcherRemover { self->chand_->state_tracker_.RemoveWatcher(self->watcher_); GRPC_CHANNEL_STACK_UNREF(self->chand_->owning_stack_, "ConnectivityWatcherRemover"); - Delete(self); + delete self; } ChannelData* chand_; @@ -1595,7 +1595,7 @@ void ChannelData::CreateResolvingLoadBalancingPolicyLocked() { lb_args.channel_control_helper = MakeUnique(this); lb_args.args = channel_args_; UniquePtr target_uri(gpr_strdup(target_uri_.get())); - resolving_lb_policy_.reset(New( + resolving_lb_policy_.reset(new ResolvingLoadBalancingPolicy( std::move(lb_args), &grpc_client_channel_routing_trace, std::move(target_uri), ProcessResolverResultLocked, this)); grpc_pollset_set_add_pollset_set(resolving_lb_policy_->interested_parties(), @@ -1964,12 +1964,12 @@ grpc_connectivity_state ChannelData::CheckConnectivityState( void ChannelData::AddConnectivityWatcher( grpc_connectivity_state initial_state, OrphanablePtr watcher) { - New(this, initial_state, std::move(watcher)); + new ConnectivityWatcherAdder(this, initial_state, std::move(watcher)); } void ChannelData::RemoveConnectivityWatcher( AsyncConnectivityStateWatcherInterface* watcher) { - New(this, watcher); + new ConnectivityWatcherRemover(this, watcher); } // @@ -3735,7 +3735,7 @@ class CallData::QueuedPickCanceller { YieldCallCombinerIfPendingBatchesFound); } GRPC_CALL_STACK_UNREF(calld->owning_call_, "QueuedPickCanceller"); - Delete(self); + delete self; } grpc_call_element* elem_; @@ -3764,7 +3764,7 @@ void CallData::AddCallToQueuedPicksLocked(grpc_call_element* elem) { pick_.elem = elem; chand->AddQueuedPick(&pick_, pollent_); // Register call combiner cancellation callback. - pick_canceller_ = New(elem); + pick_canceller_ = new QueuedPickCanceller(elem); } void CallData::ApplyServiceConfigToCallLocked(grpc_call_element* elem) { diff --git a/src/core/ext/filters/client_channel/global_subchannel_pool.cc b/src/core/ext/filters/client_channel/global_subchannel_pool.cc index b5e1feb149a..339a47728f6 100644 --- a/src/core/ext/filters/client_channel/global_subchannel_pool.cc +++ b/src/core/ext/filters/client_channel/global_subchannel_pool.cc @@ -35,7 +35,7 @@ GlobalSubchannelPool::~GlobalSubchannelPool() { } void GlobalSubchannelPool::Init() { - instance_ = New>( + instance_ = new RefCountedPtr( MakeRefCounted()); } @@ -45,7 +45,7 @@ void GlobalSubchannelPool::Shutdown() { // To ensure Shutdown() was not called before. GPR_ASSERT(*instance_ != nullptr); instance_->reset(); - Delete(instance_); + delete instance_; } RefCountedPtr GlobalSubchannelPool::instance() { @@ -78,7 +78,7 @@ Subchannel* GlobalSubchannelPool::RegisterSubchannel(SubchannelKey* key, // Note that we should ref the old map first because grpc_avl_add() will // unref it while we still need to access it later. grpc_avl new_map = grpc_avl_add( - grpc_avl_ref(old_map, nullptr), New(*key), + grpc_avl_ref(old_map, nullptr), new SubchannelKey(*key), GRPC_SUBCHANNEL_WEAK_REF(constructed, "subchannel_register+new"), nullptr); // Try to publish the change to the shared map. It may happen (but @@ -142,12 +142,12 @@ namespace { void sck_avl_destroy(void* p, void* /*user_data*/) { SubchannelKey* key = static_cast(p); - Delete(key); + delete key; } void* sck_avl_copy(void* p, void* /*unused*/) { const SubchannelKey* key = static_cast(p); - auto* new_key = New(*key); + auto* new_key = new SubchannelKey(*key); return static_cast(new_key); } diff --git a/src/core/ext/filters/client_channel/health/health_check_client.cc b/src/core/ext/filters/client_channel/health/health_check_client.cc index aa90c3dd2a5..2826dfe9685 100644 --- a/src/core/ext/filters/client_channel/health/health_check_client.cc +++ b/src/core/ext/filters/client_channel/health/health_check_client.cc @@ -400,7 +400,7 @@ void HealthCheckClient::CallState::AfterCallStackDestruction( void* arg, grpc_error* /*error*/) { HealthCheckClient::CallState* self = static_cast(arg); - Delete(self); + delete self; } void HealthCheckClient::CallState::OnCancelComplete(void* arg, diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index 26238ff2b7c..caace9a015b 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -1724,7 +1724,7 @@ grpc_channel_args* GrpcLb::CreateChildPolicyArgsLocked( OrphanablePtr GrpcLb::CreateChildPolicyLocked( const char* name, const grpc_channel_args* args) { - Helper* helper = New(Ref()); + Helper* helper = new Helper(Ref()); LoadBalancingPolicy::Args lb_policy_args; lb_policy_args.combiner = combiner(); lb_policy_args.args = args; @@ -1883,7 +1883,7 @@ class GrpcLbFactory : public LoadBalancingPolicyFactory { GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE); if (json == nullptr) { return RefCountedPtr( - New(nullptr)); + new ParsedGrpcLbConfig(nullptr)); } InlinedVector error_list; RefCountedPtr child_policy; @@ -1905,7 +1905,7 @@ class GrpcLbFactory : public LoadBalancingPolicyFactory { } if (error_list.empty()) { return RefCountedPtr( - New(std::move(child_policy))); + new ParsedGrpcLbConfig(std::move(child_policy))); } else { *error = GRPC_ERROR_CREATE_FROM_VECTOR("GrpcLb Parser", &error_list); return nullptr; diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc index 35123633feb..b6c1b03e48b 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc @@ -52,7 +52,7 @@ void GrpcLbClientStats::AddCallDropped(const char* token) { // Record the drop. MutexLock lock(&drop_count_mu_); if (drop_token_counts_ == nullptr) { - drop_token_counts_.reset(New()); + drop_token_counts_.reset(new DroppedCallCounts()); } for (size_t i = 0; i < drop_token_counts_->size(); ++i) { if (strcmp((*drop_token_counts_)[i].token.get(), token) == 0) { diff --git a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc index 1063167ec00..bc00d31f442 100644 --- a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +++ b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc @@ -495,7 +495,7 @@ class PickFirstFactory : public LoadBalancingPolicyFactory { GPR_DEBUG_ASSERT(strcmp(json->key, name()) == 0); } return RefCountedPtr( - New()); + new ParsedPickFirstConfig()); } }; diff --git a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc index b567a6ba4bf..67fbf17fda2 100644 --- a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +++ b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc @@ -491,7 +491,7 @@ class RoundRobinFactory : public LoadBalancingPolicyFactory { GPR_DEBUG_ASSERT(strcmp(json->key, name()) == 0); } return RefCountedPtr( - New()); + new ParsedRoundRobinConfig()); } }; diff --git a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h index 70acb50cf45..2e0b5e2ace5 100644 --- a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +++ b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h @@ -206,10 +206,6 @@ class SubchannelList : public InternallyRefCounted { virtual ~SubchannelList(); private: - // So New() can call our private ctor. - template - friend T* New(Args&&... args); - // For accessing Ref() and Unref(). friend class SubchannelData; @@ -317,7 +313,7 @@ void SubchannelData(this, subchannel_list()->Ref(DEBUG_LOCATION, "Watcher")); + new Watcher(this, subchannel_list()->Ref(DEBUG_LOCATION, "Watcher")); subchannel_->WatchConnectivityState( connectivity_state_, UniquePtr( diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc index fe77d6294c0..57cdec10487 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc @@ -992,7 +992,7 @@ void XdsLb::UpdateFallbackPolicyLocked() { OrphanablePtr XdsLb::CreateFallbackPolicyLocked( const char* name, const grpc_channel_args* args) { FallbackHelper* helper = - New(Ref(DEBUG_LOCATION, "FallbackHelper")); + new FallbackHelper(Ref(DEBUG_LOCATION, "FallbackHelper")); LoadBalancingPolicy::Args lb_policy_args; lb_policy_args.combiner = combiner(); lb_policy_args.args = args; @@ -1081,7 +1081,7 @@ void XdsLb::PriorityList::UpdateXdsPickerLocked() { void XdsLb::PriorityList::MaybeCreateLocalityMapLocked(uint32_t priority) { // Exhausted priorities in the update. if (!priority_list_update().Contains(priority)) return; - auto new_locality_map = New( + auto new_locality_map = new LocalityMap( xds_policy_->Ref(DEBUG_LOCATION, "XdsLb+LocalityMap"), priority); priorities_.emplace_back(OrphanablePtr(new_locality_map)); new_locality_map->UpdateLocked(*priority_list_update().Find(priority)); @@ -1500,7 +1500,7 @@ XdsLb::PriorityList::LocalityMap::Locality::CreateChildPolicyArgsLocked( OrphanablePtr XdsLb::PriorityList::LocalityMap::Locality::CreateChildPolicyLocked( const char* name, const grpc_channel_args* args) { - Helper* helper = New(this->Ref(DEBUG_LOCATION, "Helper")); + Helper* helper = new Helper(this->Ref(DEBUG_LOCATION, "Helper")); LoadBalancingPolicy::Args lb_policy_args; lb_policy_args.combiner = xds_policy()->combiner(); lb_policy_args.args = args; diff --git a/src/core/ext/filters/client_channel/lb_policy_registry.cc b/src/core/ext/filters/client_channel/lb_policy_registry.cc index c0788955419..21fcca5cd09 100644 --- a/src/core/ext/filters/client_channel/lb_policy_registry.cc +++ b/src/core/ext/filters/client_channel/lb_policy_registry.cc @@ -64,11 +64,11 @@ RegistryState* g_state = nullptr; // void LoadBalancingPolicyRegistry::Builder::InitRegistry() { - if (g_state == nullptr) g_state = New(); + if (g_state == nullptr) g_state = new RegistryState(); } void LoadBalancingPolicyRegistry::Builder::ShutdownRegistry() { - Delete(g_state); + delete g_state; g_state = nullptr; } diff --git a/src/core/ext/filters/client_channel/local_subchannel_pool.cc b/src/core/ext/filters/client_channel/local_subchannel_pool.cc index e94ede0b9cb..e57599962ad 100644 --- a/src/core/ext/filters/client_channel/local_subchannel_pool.cc +++ b/src/core/ext/filters/client_channel/local_subchannel_pool.cc @@ -43,7 +43,7 @@ Subchannel* LocalSubchannelPool::RegisterSubchannel(SubchannelKey* key, GRPC_SUBCHANNEL_UNREF(constructed, "subchannel_register+found_existing"); } else { // There hasn't been such subchannel. Add one. - subchannel_map_ = grpc_avl_add(subchannel_map_, New(*key), + subchannel_map_ = grpc_avl_add(subchannel_map_, new SubchannelKey(*key), constructed, nullptr); c = constructed; } @@ -64,12 +64,12 @@ namespace { void sck_avl_destroy(void* p, void* /*user_data*/) { SubchannelKey* key = static_cast(p); - Delete(key); + delete key; } void* sck_avl_copy(void* p, void* /*unused*/) { const SubchannelKey* key = static_cast(p); - auto new_key = New(*key); + auto new_key = new SubchannelKey(*key); return static_cast(new_key); } diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc index 621db723dc7..1d69eefdf3d 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc @@ -110,7 +110,7 @@ static void grpc_ares_ev_driver_unref(grpc_ares_ev_driver* ev_driver) { GRPC_COMBINER_UNREF(ev_driver->combiner, "free ares event driver"); ares_destroy(ev_driver->channel); grpc_ares_complete_request_locked(ev_driver->request); - grpc_core::Delete(ev_driver); + delete ev_driver; } } @@ -120,7 +120,7 @@ static void fd_node_destroy_locked(fd_node* fdn) { GPR_ASSERT(!fdn->readable_registered); GPR_ASSERT(!fdn->writable_registered); GPR_ASSERT(fdn->already_shutdown); - grpc_core::Delete(fdn->grpc_polled_fd); + delete fdn->grpc_polled_fd; gpr_free(fdn); } @@ -148,7 +148,7 @@ grpc_error* grpc_ares_ev_driver_create_locked(grpc_ares_ev_driver** ev_driver, int query_timeout_ms, grpc_core::Combiner* combiner, grpc_ares_request* request) { - *ev_driver = grpc_core::New(); + *ev_driver = new grpc_ares_ev_driver(); ares_options opts; memset(&opts, 0, sizeof(opts)); opts.flags |= ARES_FLAG_STAYOPEN; diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc index 3d7140cb4b8..f43192f778b 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc @@ -37,14 +37,14 @@ namespace grpc_core { void ares_uv_poll_cb(uv_poll_t* handle, int status, int events); -void ares_uv_poll_close_cb(uv_handle_t* handle) { Delete(handle); } +void ares_uv_poll_close_cb(uv_handle_t* handle) { delete handle; } class GrpcPolledFdLibuv : public GrpcPolledFd { public: GrpcPolledFdLibuv(ares_socket_t as, Combiner* combiner) : as_(as), combiner_(combiner) { gpr_asprintf(&name_, "c-ares socket: %" PRIdPTR, (intptr_t)as); - handle_ = New(); + handle_ = new uv_poll_t(); uv_poll_init_socket(uv_default_loop(), handle_, as); handle_->data = this; GRPC_COMBINER_REF(combiner_, "libuv ares event driver"); @@ -154,7 +154,7 @@ void ares_uv_poll_cb(uv_poll_t* handle, int status, int events) { grpc_core::ExecCtx exec_ctx; GrpcPolledFdLibuv* polled_fd = reinterpret_cast(handle->data); - AresUvPollCbArg* arg = New(handle, status, events); + AresUvPollCbArg* arg = new AresUvPollCbArg(handle, status, events); polled_fd->combiner_->Run( GRPC_CLOSURE_CREATE(ares_uv_poll_cb_locked, arg, nullptr), GRPC_ERROR_NONE); @@ -165,7 +165,7 @@ class GrpcPolledFdFactoryLibuv : public GrpcPolledFdFactory { GrpcPolledFd* NewGrpcPolledFdLocked(ares_socket_t as, grpc_pollset_set* driver_pollset_set, Combiner* combiner) override { - return New(as, combiner); + return new GrpcPolledFdLibuv(as, combiner); } void ConfigureAresChannelLocked(ares_channel channel) override {} diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc index e185116e222..eb48b6feac4 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc @@ -91,7 +91,7 @@ class GrpcPolledFdFactoryPosix : public GrpcPolledFdFactory { GrpcPolledFd* NewGrpcPolledFdLocked(ares_socket_t as, grpc_pollset_set* driver_pollset_set, Combiner* /*combiner*/) override { - return New(as, driver_pollset_set); + return new GrpcPolledFdPosix(as, driver_pollset_set); } void ConfigureAresChannelLocked(ares_channel /*channel*/) override {} diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc index 9151bee22e6..08429f6e8d4 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc @@ -752,7 +752,7 @@ class SockToPolledFdMap { } void AddNewSocket(SOCKET s, GrpcPolledFdWindows* polled_fd) { - SockToPolledFdEntry* new_node = New(s, polled_fd); + SockToPolledFdEntry* new_node = new SockToPolledFdEntry(s, polled_fd); new_node->next = head_; head_ = new_node; } @@ -775,7 +775,7 @@ class SockToPolledFdMap { node = node->next) { if (node->socket == s) { *prev = node->next; - Delete(node); + delete node; return; } prev = &node->next; @@ -805,7 +805,7 @@ class SockToPolledFdMap { } grpc_tcp_set_non_block(s); GrpcPolledFdWindows* polled_fd = - New(s, map->combiner_, af, type); + new GrpcPolledFdWindows(s, map->combiner_, af, type); GRPC_CARES_TRACE_LOG( "fd:|%s| created with params af:%d type:%d protocol:%d", polled_fd->GetName(), af, type, protocol); @@ -855,7 +855,7 @@ class SockToPolledFdMap { "Shut down c-ares fd before without it ever having made it into the " "driver's list")); } - grpc_core::Delete(polled_fd); + delete polled_fd; return 0; } @@ -920,7 +920,7 @@ class GrpcPolledFdFactoryWindows : public GrpcPolledFdFactory { // Set a flag so that the virtual socket "close" method knows it // doesn't need to call ShutdownLocked, since now the driver will. polled_fd->set_gotten_into_driver_list(); - return grpc_core::New(polled_fd); + return new GrpcPolledFdWindowsWrapper(polled_fd); } void ConfigureAresChannelLocked(ares_channel channel) override { diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc index 69257bd60cc..a1fdac1cd88 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc @@ -717,7 +717,7 @@ static void on_dns_lookup_done_locked(void* arg, grpc_error* error) { grpc_core::ExecCtx::Run(DEBUG_LOCATION, r->on_resolve_address_done, GRPC_ERROR_REF(error)); GRPC_COMBINER_UNREF(r->combiner, "on_dns_lookup_done_cb"); - grpc_core::Delete(r); + delete r; } static void on_dns_lookup_done(void* arg, grpc_error* error) { @@ -747,7 +747,7 @@ static void grpc_resolve_address_ares_impl(const char* name, grpc_closure* on_done, grpc_resolved_addresses** addrs) { grpc_resolve_address_ares_request* r = - grpc_core::New(); + new grpc_resolve_address_ares_request(); r->combiner = grpc_combiner_create(); r->addrs_out = addrs; r->on_resolve_address_done = on_done; diff --git a/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc b/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc index bba9bb749c7..906dad2b6aa 100644 --- a/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc @@ -191,7 +191,7 @@ void FakeResolverResponseGenerator::SetResponseLocked(void* arg, resolver->has_next_result_ = true; resolver->MaybeSendResultLocked(); } - Delete(closure_arg); + delete closure_arg; } void FakeResolverResponseGenerator::SetResponse(Resolver::Result result) { @@ -205,7 +205,7 @@ void FakeResolverResponseGenerator::SetResponse(Resolver::Result result) { } resolver = resolver_->Ref(); } - SetResponseClosureArg* closure_arg = New(); + SetResponseClosureArg* closure_arg = new SetResponseClosureArg(); closure_arg->resolver = std::move(resolver); closure_arg->result = std::move(result); closure_arg->resolver->combiner()->Run( @@ -222,7 +222,7 @@ void FakeResolverResponseGenerator::SetReresolutionResponseLocked( resolver->reresolution_result_ = std::move(closure_arg->result); resolver->has_reresolution_result_ = closure_arg->has_result; } - Delete(closure_arg); + delete closure_arg; } void FakeResolverResponseGenerator::SetReresolutionResponse( @@ -233,7 +233,7 @@ void FakeResolverResponseGenerator::SetReresolutionResponse( GPR_ASSERT(resolver_ != nullptr); resolver = resolver_->Ref(); } - SetResponseClosureArg* closure_arg = New(); + SetResponseClosureArg* closure_arg = new SetResponseClosureArg(); closure_arg->resolver = std::move(resolver); closure_arg->result = std::move(result); closure_arg->has_result = true; @@ -250,7 +250,7 @@ void FakeResolverResponseGenerator::UnsetReresolutionResponse() { GPR_ASSERT(resolver_ != nullptr); resolver = resolver_->Ref(); } - SetResponseClosureArg* closure_arg = New(); + SetResponseClosureArg* closure_arg = new SetResponseClosureArg(); closure_arg->resolver = std::move(resolver); closure_arg->resolver->combiner()->Run( GRPC_CLOSURE_INIT(&closure_arg->set_response_closure, @@ -266,7 +266,7 @@ void FakeResolverResponseGenerator::SetFailureLocked(void* arg, resolver->return_failure_ = true; if (closure_arg->immediate) resolver->MaybeSendResultLocked(); } - Delete(closure_arg); + delete closure_arg; } void FakeResolverResponseGenerator::SetFailure() { @@ -276,7 +276,7 @@ void FakeResolverResponseGenerator::SetFailure() { GPR_ASSERT(resolver_ != nullptr); resolver = resolver_->Ref(); } - SetResponseClosureArg* closure_arg = New(); + SetResponseClosureArg* closure_arg = new SetResponseClosureArg(); closure_arg->resolver = std::move(resolver); closure_arg->resolver->combiner()->Run( GRPC_CLOSURE_INIT(&closure_arg->set_response_closure, SetFailureLocked, @@ -291,7 +291,7 @@ void FakeResolverResponseGenerator::SetFailureOnReresolution() { GPR_ASSERT(resolver_ != nullptr); resolver = resolver_->Ref(); } - SetResponseClosureArg* closure_arg = New(); + SetResponseClosureArg* closure_arg = new SetResponseClosureArg(); closure_arg->resolver = std::move(resolver); closure_arg->immediate = false; closure_arg->resolver->combiner()->Run( @@ -306,7 +306,7 @@ void FakeResolverResponseGenerator::SetFakeResolver( resolver_ = std::move(resolver); if (resolver_ == nullptr) return; if (has_result_) { - SetResponseClosureArg* closure_arg = New(); + SetResponseClosureArg* closure_arg = new SetResponseClosureArg(); closure_arg->resolver = resolver_->Ref(); closure_arg->result = std::move(result_); resolver_->combiner()->Run( diff --git a/src/core/ext/filters/client_channel/resolver_registry.cc b/src/core/ext/filters/client_channel/resolver_registry.cc index 0776551a9b6..fd34b9c856c 100644 --- a/src/core/ext/filters/client_channel/resolver_registry.cc +++ b/src/core/ext/filters/client_channel/resolver_registry.cc @@ -103,11 +103,11 @@ static RegistryState* g_state = nullptr; // void ResolverRegistry::Builder::InitRegistry() { - if (g_state == nullptr) g_state = New(); + if (g_state == nullptr) g_state = new RegistryState(); } void ResolverRegistry::Builder::ShutdownRegistry() { - Delete(g_state); + delete g_state; g_state = nullptr; } diff --git a/src/core/ext/filters/client_channel/resolving_lb_policy.cc b/src/core/ext/filters/client_channel/resolving_lb_policy.cc index 9cac0ed702c..15182000dc5 100644 --- a/src/core/ext/filters/client_channel/resolving_lb_policy.cc +++ b/src/core/ext/filters/client_channel/resolving_lb_policy.cc @@ -371,7 +371,7 @@ OrphanablePtr ResolvingLoadBalancingPolicy::CreateLbPolicyLocked( const char* lb_policy_name, const grpc_channel_args& args, TraceStringVector* trace_strings) { - ResolvingControlHelper* helper = New(Ref()); + ResolvingControlHelper* helper = new ResolvingControlHelper(Ref()); LoadBalancingPolicy::Args lb_policy_args; lb_policy_args.combiner = combiner(); lb_policy_args.channel_control_helper = diff --git a/src/core/ext/filters/client_channel/service_config.cc b/src/core/ext/filters/client_channel/service_config.cc index d41859bf45a..3a089f5b442 100644 --- a/src/core/ext/filters/client_channel/service_config.cc +++ b/src/core/ext/filters/client_channel/service_config.cc @@ -318,11 +318,11 @@ size_t ServiceConfig::RegisterParser(UniquePtr parser) { void ServiceConfig::Init() { GPR_ASSERT(g_registered_parsers == nullptr); - g_registered_parsers = New(); + g_registered_parsers = new ServiceConfigParserList(); } void ServiceConfig::Shutdown() { - Delete(g_registered_parsers); + delete g_registered_parsers; g_registered_parsers = nullptr; } diff --git a/src/core/ext/filters/client_channel/service_config.h b/src/core/ext/filters/client_channel/service_config.h index 1eac424d628..e510c599e0c 100644 --- a/src/core/ext/filters/client_channel/service_config.h +++ b/src/core/ext/filters/client_channel/service_config.h @@ -128,6 +128,10 @@ class ServiceConfig : public RefCounted { static RefCountedPtr Create(const char* json, grpc_error** error); + // Takes ownership of \a json_tree. + ServiceConfig(UniquePtr service_config_json, + UniquePtr json_string, grpc_json* json_tree, + grpc_error** error); ~ServiceConfig(); const char* service_config_json() const { return service_config_json_.get(); } @@ -158,15 +162,6 @@ class ServiceConfig : public RefCounted { static void Shutdown(); private: - // So New() can call our private ctor. - template - friend T* New(Args&&... args); - - // Takes ownership of \a json_tree. - ServiceConfig(UniquePtr service_config_json, - UniquePtr json_string, grpc_json* json_tree, - grpc_error** error); - // Helper functions to parse the service config grpc_error* ParseGlobalParams(const grpc_json* json_tree); grpc_error* ParsePerMethodParams(const grpc_json* json_tree); diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index c61616aafda..d7a7f1be1b0 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -669,21 +669,21 @@ Subchannel::~Subchannel() { grpc_channel_args_destroy(args_); grpc_connector_unref(connector_); grpc_pollset_set_destroy(pollset_set_); - Delete(key_); + delete key_; } Subchannel* Subchannel::Create(grpc_connector* connector, const grpc_channel_args* args) { - SubchannelKey* key = New(args); + SubchannelKey* key = new SubchannelKey(args); SubchannelPoolInterface* subchannel_pool = SubchannelPoolInterface::GetSubchannelPoolFromChannelArgs(args); GPR_ASSERT(subchannel_pool != nullptr); Subchannel* c = subchannel_pool->FindSubchannel(key); if (c != nullptr) { - Delete(key); + delete key; return c; } - c = New(key, connector, args); + c = new Subchannel(key, connector, args); // Try to register the subchannel before setting the subchannel pool. // Otherwise, in case of a registration race, unreffing c in // RegisterSubchannel() will cause c to be tried to be unregistered, while @@ -724,7 +724,7 @@ namespace { void subchannel_destroy(void* arg, grpc_error* /*error*/) { Subchannel* self = static_cast(arg); - Delete(self); + delete self; } } // namespace @@ -1050,7 +1050,7 @@ bool Subchannel::PublishTransportLocked() { } // Publish. connected_subchannel_.reset( - New(stk, args_, channelz_node_)); + new ConnectedSubchannel(stk, args_, channelz_node_)); gpr_log(GPR_INFO, "New connected subchannel at %p for subchannel %p", connected_subchannel_.get(), this); if (channelz_node_ != nullptr) { diff --git a/src/core/ext/filters/client_channel/xds/xds_client.cc b/src/core/ext/filters/client_channel/xds/xds_client.cc index 3b1e535426b..2f9ef9e2a61 100644 --- a/src/core/ext/filters/client_channel/xds/xds_client.cc +++ b/src/core/ext/filters/client_channel/xds/xds_client.cc @@ -378,16 +378,16 @@ bool XdsClient::ChannelState::HasActiveAdsCall() const { void XdsClient::ChannelState::MaybeStartAdsCall() { if (ads_calld_ != nullptr) return; - ads_calld_.reset(New>( - Ref(DEBUG_LOCATION, "ChannelState+ads"))); + ads_calld_.reset( + new RetryableCall(Ref(DEBUG_LOCATION, "ChannelState+ads"))); } void XdsClient::ChannelState::StopAdsCall() { ads_calld_.reset(); } void XdsClient::ChannelState::MaybeStartLrsCall() { if (lrs_calld_ != nullptr) return; - lrs_calld_.reset(New>( - Ref(DEBUG_LOCATION, "ChannelState+lrs"))); + lrs_calld_.reset( + new RetryableCall(Ref(DEBUG_LOCATION, "ChannelState+lrs"))); } void XdsClient::ChannelState::StopLrsCall() { lrs_calld_.reset(); } @@ -396,7 +396,7 @@ void XdsClient::ChannelState::StartConnectivityWatchLocked() { grpc_channel_element* client_channel_elem = grpc_channel_stack_last_element(grpc_channel_get_channel_stack(channel_)); GPR_ASSERT(client_channel_elem->filter == &grpc_client_channel_filter); - watcher_ = New(Ref()); + watcher_ = new StateWatcher(Ref()); grpc_client_channel_start_connectivity_watch( client_channel_elem, GRPC_CHANNEL_IDLE, OrphanablePtr(watcher_)); diff --git a/src/core/ext/filters/deadline/deadline_filter.cc b/src/core/ext/filters/deadline/deadline_filter.cc index 1ea170ec595..f6f55d795de 100644 --- a/src/core/ext/filters/deadline/deadline_filter.cc +++ b/src/core/ext/filters/deadline/deadline_filter.cc @@ -175,7 +175,7 @@ static void start_timer_after_init(void* arg, grpc_error* error) { "scheduling deadline timer"); return; } - grpc_core::Delete(state); + delete state; GRPC_CALL_COMBINER_STOP(deadline_state->call_combiner, "done scheduling deadline timer"); } @@ -196,7 +196,7 @@ grpc_deadline_state::grpc_deadline_state(grpc_call_element* elem, // create a closure to start the timer, and we schedule that closure // to be run after call stack initialization is done. struct start_timer_after_init_state* state = - grpc_core::New(elem, deadline); + new start_timer_after_init_state(elem, deadline); GRPC_CLOSURE_INIT(&state->closure, start_timer_after_init, state, grpc_schedule_on_exec_ctx); grpc_core::ExecCtx::Run(DEBUG_LOCATION, &state->closure, GRPC_ERROR_NONE); diff --git a/src/core/ext/filters/max_age/max_age_filter.cc b/src/core/ext/filters/max_age/max_age_filter.cc index b926be7018c..0cf6f542414 100644 --- a/src/core/ext/filters/max_age/max_age_filter.cc +++ b/src/core/ext/filters/max_age/max_age_filter.cc @@ -267,8 +267,7 @@ static void start_max_age_timer_after_init(void* arg, grpc_error* /*error*/) { &chand->close_max_age_channel); gpr_mu_unlock(&chand->max_age_timer_mu); grpc_transport_op* op = grpc_make_transport_op(nullptr); - op->start_connectivity_watch.reset( - grpc_core::New(chand)); + op->start_connectivity_watch.reset(new grpc_core::ConnectivityWatcher(chand)); op->start_connectivity_watch_state = GRPC_CHANNEL_IDLE; grpc_channel_next_op(grpc_channel_stack_element(chand->channel_stack, 0), op); GRPC_CHANNEL_STACK_UNREF(chand->channel_stack, diff --git a/src/core/ext/transport/chttp2/client/insecure/channel_create.cc b/src/core/ext/transport/chttp2/client/insecure/channel_create.cc index aaa978995df..9bf975e8796 100644 --- a/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +++ b/src/core/ext/transport/chttp2/client/insecure/channel_create.cc @@ -79,7 +79,7 @@ grpc_core::Chttp2InsecureClientChannelFactory* g_factory; gpr_once g_factory_once = GPR_ONCE_INIT; void FactoryInit() { - g_factory = grpc_core::New(); + g_factory = new grpc_core::Chttp2InsecureClientChannelFactory(); } } // namespace diff --git a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc index 95410cff7b3..49389844e00 100644 --- a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +++ b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc @@ -181,7 +181,7 @@ grpc_core::Chttp2SecureClientChannelFactory* g_factory; gpr_once g_factory_once = GPR_ONCE_INIT; void FactoryInit() { - g_factory = grpc_core::New(); + g_factory = new grpc_core::Chttp2SecureClientChannelFactory(); } } // namespace diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index e6f37b89ef0..e0aa8e5d9c8 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -3322,8 +3322,8 @@ grpc_chttp2_transport_get_socket_node(grpc_transport* transport) { grpc_transport* grpc_create_chttp2_transport( const grpc_channel_args* channel_args, grpc_endpoint* ep, bool is_client, grpc_resource_user* resource_user) { - auto t = grpc_core::New(channel_args, ep, is_client, - resource_user); + auto t = + new grpc_chttp2_transport(channel_args, ep, is_client, resource_user); return &t->base; } diff --git a/src/core/ext/transport/chttp2/transport/context_list.cc b/src/core/ext/transport/chttp2/transport/context_list.cc index 245e8135833..a0473ea822a 100644 --- a/src/core/ext/transport/chttp2/transport/context_list.cc +++ b/src/core/ext/transport/chttp2/transport/context_list.cc @@ -33,7 +33,7 @@ void ContextList::Append(ContextList** head, grpc_chttp2_stream* s) { return; } /* Create a new element in the list and add it at the front */ - ContextList* elem = grpc_core::New(); + ContextList* elem = new ContextList(); elem->trace_context_ = get_copied_context_fn_g(s->context); elem->byte_offset_ = s->byte_counter; elem->next_ = *head; @@ -53,7 +53,7 @@ void ContextList::Execute(void* arg, grpc_core::Timestamps* ts, } to_be_freed = head; head = head->next_; - grpc_core::Delete(to_be_freed); + delete to_be_freed; } } diff --git a/src/core/ext/transport/chttp2/transport/frame_data.cc b/src/core/ext/transport/chttp2/transport/frame_data.cc index f2ff4d37b77..d815654c31c 100644 --- a/src/core/ext/transport/chttp2/transport/frame_data.cc +++ b/src/core/ext/transport/chttp2/transport/frame_data.cc @@ -193,7 +193,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames( if (p->is_frame_compressed) { message_flags |= GRPC_WRITE_INTERNAL_COMPRESS; } - p->parsing_frame = grpc_core::New( + p->parsing_frame = new grpc_core::Chttp2IncomingByteStream( t, s, p->frame_size, message_flags); stream_out->reset(p->parsing_frame); if (p->parsing_frame->remaining_bytes() == 0) { diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 845a94e919c..fa3d882c715 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -239,7 +239,7 @@ class Chttp2IncomingByteStream : public ByteStream { void Ref() { refs_.Ref(); } void Unref() { if (GPR_UNLIKELY(refs_.Unref())) { - grpc_core::Delete(this); + delete this; } } @@ -814,7 +814,7 @@ inline void grpc_chttp2_unref_transport(grpc_chttp2_transport* t, const char* reason, const char* file, int line) { if (t->refs.Unref(grpc_core::DebugLocation(file, line), reason)) { - grpc_core::Delete(t); + delete t; } } inline void grpc_chttp2_ref_transport(grpc_chttp2_transport* t, @@ -827,7 +827,7 @@ inline void grpc_chttp2_ref_transport(grpc_chttp2_transport* t, #define GRPC_CHTTP2_UNREF_TRANSPORT(t, r) grpc_chttp2_unref_transport(t) inline void grpc_chttp2_unref_transport(grpc_chttp2_transport* t) { if (t->refs.Unref()) { - grpc_core::Delete(t); + delete t; } } inline void grpc_chttp2_ref_transport(grpc_chttp2_transport* t) { diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.cc b/src/core/ext/transport/cronet/transport/cronet_transport.cc index 8cc4becfff9..acdc3fc1ff1 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.cc +++ b/src/core/ext/transport/cronet/transport/cronet_transport.cc @@ -335,7 +335,7 @@ static void add_to_storage(struct stream_obj* s, struct op_storage* storage = &s->storage; /* add new op at the beginning of the linked list. The memory is freed in remove_from_storage */ - op_and_state* new_op = grpc_core::New(s, *op); + op_and_state* new_op = new op_and_state(s, *op); gpr_mu_lock(&s->mu); new_op->next = storage->head; storage->head = new_op; @@ -363,7 +363,7 @@ static void remove_from_storage(struct stream_obj* s, } if (s->storage.head == oas) { s->storage.head = oas->next; - grpc_core::Delete(oas); + delete oas; s->storage.num_pending_ops--; CRONET_LOG(GPR_DEBUG, "Freed %p. Now %d in the queue", oas, s->storage.num_pending_ops); @@ -374,7 +374,7 @@ static void remove_from_storage(struct stream_obj* s, s->storage.num_pending_ops--; CRONET_LOG(GPR_DEBUG, "Freed %p. Now %d in the queue", oas, s->storage.num_pending_ops); - grpc_core::Delete(oas); + delete oas; break; } else if (GPR_UNLIKELY(curr->next == nullptr)) { CRONET_LOG(GPR_ERROR, "Reached end of LL and did not find op to free"); diff --git a/src/core/lib/channel/channel_trace.cc b/src/core/lib/channel/channel_trace.cc index d329ccc98de..b6fcd0f87bf 100644 --- a/src/core/lib/channel/channel_trace.cc +++ b/src/core/lib/channel/channel_trace.cc @@ -81,7 +81,7 @@ ChannelTrace::~ChannelTrace() { while (it != nullptr) { TraceEvent* to_free = it; it = it->next(); - Delete(to_free); + delete to_free; } gpr_mu_destroy(&tracer_mu_); } @@ -103,7 +103,7 @@ void ChannelTrace::AddTraceEventHelper(TraceEvent* new_trace_event) { TraceEvent* to_free = head_trace_; event_list_memory_usage_ -= to_free->memory_usage(); head_trace_ = head_trace_->next(); - Delete(to_free); + delete to_free; } } @@ -112,7 +112,7 @@ void ChannelTrace::AddTraceEvent(Severity severity, const grpc_slice& data) { grpc_slice_unref_internal(data); return; // tracing is disabled if max_event_memory_ == 0 } - AddTraceEventHelper(New(severity, data)); + AddTraceEventHelper(new TraceEvent(severity, data)); } void ChannelTrace::AddTraceEventWithReference( @@ -124,7 +124,7 @@ void ChannelTrace::AddTraceEventWithReference( } // create and fill up the new event AddTraceEventHelper( - New(severity, data, std::move(referenced_entity))); + new TraceEvent(severity, data, std::move(referenced_entity))); } namespace { diff --git a/src/core/lib/channel/channelz_registry.cc b/src/core/lib/channel/channelz_registry.cc index 553e1fe97b5..e0c9c8e67f3 100644 --- a/src/core/lib/channel/channelz_registry.cc +++ b/src/core/lib/channel/channelz_registry.cc @@ -43,9 +43,9 @@ const int kPaginationLimit = 100; } // anonymous namespace -void ChannelzRegistry::Init() { g_channelz_registry = New(); } +void ChannelzRegistry::Init() { g_channelz_registry = new ChannelzRegistry(); } -void ChannelzRegistry::Shutdown() { Delete(g_channelz_registry); } +void ChannelzRegistry::Shutdown() { delete g_channelz_registry; } ChannelzRegistry* ChannelzRegistry::Default() { GPR_DEBUG_ASSERT(g_channelz_registry != nullptr); diff --git a/src/core/lib/gprpp/fork.cc b/src/core/lib/gprpp/fork.cc index 51836d52cf4..92377a0e881 100644 --- a/src/core/lib/gprpp/fork.cc +++ b/src/core/lib/gprpp/fork.cc @@ -172,15 +172,15 @@ void Fork::GlobalInit() { MemoryOrder::RELAXED); } if (support_enabled_.Load(MemoryOrder::RELAXED)) { - exec_ctx_state_ = grpc_core::New(); - thread_state_ = grpc_core::New(); + exec_ctx_state_ = new internal::ExecCtxState(); + thread_state_ = new internal::ThreadState(); } } void Fork::GlobalShutdown() { if (support_enabled_.Load(MemoryOrder::RELAXED)) { - grpc_core::Delete(exec_ctx_state_); - grpc_core::Delete(thread_state_); + delete exec_ctx_state_; + delete thread_state_; } } diff --git a/src/core/lib/gprpp/memory.h b/src/core/lib/gprpp/memory.h index 9a1628b6ec0..adbd0035bc4 100644 --- a/src/core/lib/gprpp/memory.h +++ b/src/core/lib/gprpp/memory.h @@ -30,13 +30,6 @@ namespace grpc_core { -// Alternative to new, to ensure memory allocation being wrapped to gpr_malloc -template -inline T* New(Args&&... args) { - void* p = gpr_malloc(sizeof(T)); - return new (p) T(std::forward(args)...); -} - // Gets the base pointer of any class, in case of multiple inheritance. // Used by Delete and friends. template @@ -49,36 +42,12 @@ struct BasePointerGetter { static void* get(T* p) { return dynamic_cast(p); } }; -// Alternative to delete, to ensure memory allocation being wrapped to gpr_free template -inline void Delete(T* p) { - if (p == nullptr) return; - void* basePtr = BasePointerGetter::value>::get(p); - p->~T(); - gpr_free(basePtr); -} - -class DefaultDelete { - public: - template - void operator()(T* p) { - // Delete() checks whether the value is null, but std::unique_ptr<> is - // guaranteed not to call the deleter if the pointer is nullptr - // (i.e., it already does this check for us), and we don't want to - // do the check twice. So, instead of calling Delete() here, we - // manually call the object's dtor and free it. - void* basePtr = BasePointerGetter::value>::get(p); - p->~T(); - gpr_free(basePtr); - } -}; - -template -using UniquePtr = std::unique_ptr; +using UniquePtr = std::unique_ptr; template inline UniquePtr MakeUnique(Args&&... args) { - return UniquePtr(New(std::forward(args)...)); + return UniquePtr(new T(std::forward(args)...)); } // an allocator that uses gpr_malloc/gpr_free diff --git a/src/core/lib/gprpp/orphanable.h b/src/core/lib/gprpp/orphanable.h index db9547d2224..c3bd9e1eb71 100644 --- a/src/core/lib/gprpp/orphanable.h +++ b/src/core/lib/gprpp/orphanable.h @@ -69,7 +69,7 @@ using OrphanablePtr = std::unique_ptr; template inline OrphanablePtr MakeOrphanable(Args&&... args) { - return OrphanablePtr(New(std::forward(args)...)); + return OrphanablePtr(new T(std::forward(args)...)); } // A type of Orphanable with internal ref-counting. @@ -106,12 +106,12 @@ class InternallyRefCounted : public Orphanable { void Unref() { if (GPR_UNLIKELY(refs_.Unref())) { - Delete(static_cast(this)); + delete static_cast(this); } } void Unref(const DebugLocation& location, const char* reason) { if (GPR_UNLIKELY(refs_.Unref(location, reason))) { - Delete(static_cast(this)); + delete static_cast(this); } } diff --git a/src/core/lib/gprpp/ref_counted.h b/src/core/lib/gprpp/ref_counted.h index e8288a34286..44070e58bf1 100644 --- a/src/core/lib/gprpp/ref_counted.h +++ b/src/core/lib/gprpp/ref_counted.h @@ -220,7 +220,7 @@ class RefCount { // A base class for reference-counted objects. // New objects should be created via New() and start with a refcount of 1. -// When the refcount reaches 0, the object will be deleted via Delete(). +// When the refcount reaches 0, the object will be deleted via delete . // // This will commonly be used by CRTP (curiously-recurring template pattern) // e.g., class MyClass : public RefCounted @@ -267,12 +267,12 @@ class RefCounted : public Impl { // friend of this class. void Unref() { if (GPR_UNLIKELY(refs_.Unref())) { - Delete(static_cast(this)); + delete static_cast(this); } } void Unref(const DebugLocation& location, const char* reason) { if (GPR_UNLIKELY(refs_.Unref(location, reason))) { - Delete(static_cast(this)); + delete static_cast(this); } } diff --git a/src/core/lib/gprpp/ref_counted_ptr.h b/src/core/lib/gprpp/ref_counted_ptr.h index 2e3f4671581..4c5b46538a8 100644 --- a/src/core/lib/gprpp/ref_counted_ptr.h +++ b/src/core/lib/gprpp/ref_counted_ptr.h @@ -179,7 +179,7 @@ class RefCountedPtr { template inline RefCountedPtr MakeRefCounted(Args&&... args) { - return RefCountedPtr(New(std::forward(args)...)); + return RefCountedPtr(new T(std::forward(args)...)); } } // namespace grpc_core diff --git a/src/core/lib/gprpp/thd.h b/src/core/lib/gprpp/thd.h index 223e4115b87..8e50f545e25 100644 --- a/src/core/lib/gprpp/thd.h +++ b/src/core/lib/gprpp/thd.h @@ -144,7 +144,7 @@ class Thread { void Join() { if (impl_ != nullptr) { impl_->Join(); - grpc_core::Delete(impl_); + delete impl_; state_ = DONE; impl_ = nullptr; } else { diff --git a/src/core/lib/gprpp/thd_posix.cc b/src/core/lib/gprpp/thd_posix.cc index 2c3ae34ed44..788b47b99b1 100644 --- a/src/core/lib/gprpp/thd_posix.cc +++ b/src/core/lib/gprpp/thd_posix.cc @@ -133,7 +133,7 @@ class ThreadInternalsPosix : public internal::ThreadInternalsInterface { gpr_mu_unlock(&arg.thread->mu_); if (!arg.joinable) { - Delete(arg.thread); + delete arg.thread; } (*arg.body)(arg.arg); @@ -182,12 +182,12 @@ Thread::Thread(const char* thd_name, void (*thd_body)(void* arg), void* arg, bool* success, const Options& options) : options_(options) { bool outcome = false; - impl_ = New(thd_name, thd_body, arg, &outcome, options); + impl_ = new ThreadInternalsPosix(thd_name, thd_body, arg, &outcome, options); if (outcome) { state_ = ALIVE; } else { state_ = FAILED; - Delete(impl_); + delete impl_; impl_ = nullptr; } diff --git a/src/core/lib/gprpp/thd_windows.cc b/src/core/lib/gprpp/thd_windows.cc index 5014444dcfd..bd3b7a36ebb 100644 --- a/src/core/lib/gprpp/thd_windows.cc +++ b/src/core/lib/gprpp/thd_windows.cc @@ -121,7 +121,7 @@ class ThreadInternalsWindows } gpr_mu_unlock(&g_thd_info->thread->mu_); if (!g_thd_info->joinable) { - grpc_core::Delete(g_thd_info->thread); + delete g_thd_info->thread; g_thd_info->thread = nullptr; } g_thd_info->body(g_thd_info->arg); @@ -155,12 +155,12 @@ Thread::Thread(const char* thd_name, void (*thd_body)(void* arg), void* arg, bool* success, const Options& options) : options_(options) { bool outcome = false; - impl_ = New(thd_body, arg, &outcome, options); + impl_ = new ThreadInternalsWindows(thd_body, arg, &outcome, options); if (outcome) { state_ = ALIVE; } else { state_ = FAILED; - Delete(impl_); + delete impl_; impl_ = nullptr; } diff --git a/src/core/lib/http/httpcli_security_connector.cc b/src/core/lib/http/httpcli_security_connector.cc index 5d8d177fe67..3d95cdfea9a 100644 --- a/src/core/lib/http/httpcli_security_connector.cc +++ b/src/core/lib/http/httpcli_security_connector.cc @@ -174,13 +174,13 @@ static void on_handshake_done(void* arg, grpc_error* error) { gpr_free(args->read_buffer); c->func(c->arg, args->endpoint); } - grpc_core::Delete(c); + delete c; } static void ssl_handshake(void* arg, grpc_endpoint* tcp, const char* host, grpc_millis deadline, void (*on_done)(void* arg, grpc_endpoint* endpoint)) { - auto* c = grpc_core::New(); + auto* c = new on_done_closure(); const char* pem_root_certs = grpc_core::DefaultSslRootStore::GetPemRootCerts(); const tsi_ssl_root_certs_store* root_store = diff --git a/src/core/lib/iomgr/buffer_list.cc b/src/core/lib/iomgr/buffer_list.cc index 722e9036b32..9123cd3aa6d 100644 --- a/src/core/lib/iomgr/buffer_list.cc +++ b/src/core/lib/iomgr/buffer_list.cc @@ -197,7 +197,7 @@ static int get_socket_tcp_info(grpc_core::tcp_info* info, int fd) { void TracedBuffer::AddNewEntry(TracedBuffer** head, uint32_t seq_no, int fd, void* arg) { GPR_DEBUG_ASSERT(head != nullptr); - TracedBuffer* new_elem = New(seq_no, arg); + TracedBuffer* new_elem = new TracedBuffer(seq_no, arg); /* Store the current time as the sendmsg time. */ new_elem->ts_.sendmsg_time.time = gpr_now(GPR_CLOCK_REALTIME); new_elem->ts_.scheduled_time.time = gpr_inf_past(GPR_CLOCK_REALTIME); @@ -254,7 +254,7 @@ void TracedBuffer::ProcessTimestamp(TracedBuffer** head, * restriction on the lifetime. */ timestamps_callback(elem->arg_, &(elem->ts_), GRPC_ERROR_NONE); next = elem->next_; - Delete(elem); + delete static_cast(elem); *head = elem = next; break; default: @@ -273,7 +273,7 @@ void TracedBuffer::Shutdown(TracedBuffer** head, void* remaining, while (elem != nullptr) { timestamps_callback(elem->arg_, &(elem->ts_), shutdown_err); auto* next = elem->next_; - Delete(elem); + delete elem; elem = next; } *head = nullptr; diff --git a/src/core/lib/iomgr/cfstream_handle.cc b/src/core/lib/iomgr/cfstream_handle.cc index c1e7d67e568..40fb3779651 100644 --- a/src/core/lib/iomgr/cfstream_handle.cc +++ b/src/core/lib/iomgr/cfstream_handle.cc @@ -53,7 +53,7 @@ void CFStreamHandle::Release(void* info) { CFStreamHandle* CFStreamHandle::CreateStreamHandle( CFReadStreamRef read_stream, CFWriteStreamRef write_stream) { - return grpc_core::New(read_stream, write_stream); + return new CFStreamHandle(read_stream, write_stream); } void CFStreamHandle::ReadCallback(CFReadStreamRef stream, @@ -194,7 +194,7 @@ void CFStreamHandle::Unref(const char* file, int line, const char* reason) { reason, val, val - 1); } if (gpr_unref(&refcount_)) { - grpc_core::Delete(this); + delete this; } } diff --git a/src/core/lib/iomgr/combiner.cc b/src/core/lib/iomgr/combiner.cc index bc41393a6cd..884c7f211f3 100644 --- a/src/core/lib/iomgr/combiner.cc +++ b/src/core/lib/iomgr/combiner.cc @@ -53,7 +53,7 @@ static void combiner_finally_exec(grpc_core::Combiner* lock, static void offload(void* arg, grpc_error* error); grpc_core::Combiner* grpc_combiner_create(void) { - grpc_core::Combiner* lock = grpc_core::New(); + grpc_core::Combiner* lock = new grpc_core::Combiner(); gpr_ref_init(&lock->refs, 1); gpr_atm_no_barrier_store(&lock->state, STATE_UNORPHANED); grpc_closure_list_init(&lock->final_list); @@ -65,7 +65,7 @@ grpc_core::Combiner* grpc_combiner_create(void) { static void really_destroy(grpc_core::Combiner* lock) { GRPC_COMBINER_TRACE(gpr_log(GPR_INFO, "C:%p really_destroy", lock)); GPR_ASSERT(gpr_atm_no_barrier_load(&lock->state) == 0); - grpc_core::Delete(lock); + delete lock; } static void start_destroy(grpc_core::Combiner* lock) { diff --git a/src/core/lib/iomgr/executor.cc b/src/core/lib/iomgr/executor.cc index 5028b8597fa..63d946c2479 100644 --- a/src/core/lib/iomgr/executor.cc +++ b/src/core/lib/iomgr/executor.cc @@ -393,9 +393,9 @@ void Executor::InitAll() { } executors[static_cast(ExecutorType::DEFAULT)] = - grpc_core::New("default-executor"); + new Executor("default-executor"); executors[static_cast(ExecutorType::RESOLVER)] = - grpc_core::New("resolver-executor"); + new Executor("resolver-executor"); executors[static_cast(ExecutorType::DEFAULT)]->Init(); executors[static_cast(ExecutorType::RESOLVER)]->Init(); @@ -425,7 +425,7 @@ void Executor::ShutdownAll() { // Delete the executor objects. // // NOTE: It is important to call Shutdown() on all executors first before - // calling Delete() because it is possible for one executor (that is not + // calling delete because it is possible for one executor (that is not // shutdown yet) to call Enqueue() on a different executor which is already // shutdown. This is legal and in such cases, the Enqueue() operation // effectively "fails" and enqueues that closure on the calling thread's @@ -434,10 +434,8 @@ void Executor::ShutdownAll() { // By ensuring that all executors are shutdown first, we are also ensuring // that no thread is active across all executors. - grpc_core::Delete( - executors[static_cast(ExecutorType::DEFAULT)]); - grpc_core::Delete( - executors[static_cast(ExecutorType::RESOLVER)]); + delete executors[static_cast(ExecutorType::DEFAULT)]; + delete executors[static_cast(ExecutorType::RESOLVER)]; executors[static_cast(ExecutorType::DEFAULT)] = nullptr; executors[static_cast(ExecutorType::RESOLVER)] = nullptr; diff --git a/src/core/lib/iomgr/executor/threadpool.cc b/src/core/lib/iomgr/executor/threadpool.cc index 8c9fd18380e..859c49a3eab 100644 --- a/src/core/lib/iomgr/executor/threadpool.cc +++ b/src/core/lib/iomgr/executor/threadpool.cc @@ -54,11 +54,11 @@ void ThreadPool::SharedThreadPoolConstructor() { // Create at least 1 worker thread. if (num_threads_ <= 0) num_threads_ = 1; - queue_ = New(); + queue_ = new InfLenFIFOQueue(); threads_ = static_cast( gpr_zalloc(num_threads_ * sizeof(ThreadPoolWorker*))); for (int i = 0; i < num_threads_; ++i) { - threads_[i] = New(thd_name_, queue_, thread_options_, i); + threads_[i] = new ThreadPoolWorker(thd_name_, queue_, thread_options_, i); threads_[i]->Start(); } } @@ -114,10 +114,10 @@ ThreadPool::~ThreadPool() { } for (int i = 0; i < num_threads_; ++i) { - Delete(threads_[i]); + delete threads_[i]; } gpr_free(threads_); - Delete(queue_); + delete queue_; } void ThreadPool::Add(grpc_experimental_completion_queue_functor* closure) { diff --git a/src/core/lib/iomgr/resolve_address_custom.cc b/src/core/lib/iomgr/resolve_address_custom.cc index 5c081309c7d..1d5230d74d0 100644 --- a/src/core/lib/iomgr/resolve_address_custom.cc +++ b/src/core/lib/iomgr/resolve_address_custom.cc @@ -92,7 +92,7 @@ static grpc_error* try_split_host_port(const char* name, grpc_core::UniquePtr* port) { /* parse name, splitting it into host and port parts */ grpc_error* error; - SplitHostPort(name, host, port); + grpc_core::SplitHostPort(name, host, port); if (*host == nullptr) { char* msg; gpr_asprintf(&msg, "unparseable host:port: '%s'", name); diff --git a/src/core/lib/iomgr/tcp_server_posix.cc b/src/core/lib/iomgr/tcp_server_posix.cc index eb4d3cbdef6..a9bf800e362 100644 --- a/src/core/lib/iomgr/tcp_server_posix.cc +++ b/src/core/lib/iomgr/tcp_server_posix.cc @@ -120,7 +120,7 @@ static void finish_shutdown(grpc_tcp_server* s) { gpr_free(sp); } grpc_channel_args_destroy(s->channel_args); - grpc_core::Delete(s->fd_handler); + delete s->fd_handler; gpr_free(s); } @@ -623,7 +623,7 @@ class ExternalConnectionHandler : public grpc_core::TcpServerFdHandler { static grpc_core::TcpServerFdHandler* tcp_server_create_fd_handler( grpc_tcp_server* s) { - s->fd_handler = grpc_core::New(s); + s->fd_handler = new ExternalConnectionHandler(s); return s->fd_handler; } diff --git a/src/core/lib/iomgr/udp_server.cc b/src/core/lib/iomgr/udp_server.cc index 8bac6dd6a2d..2afef07907b 100644 --- a/src/core/lib/iomgr/udp_server.cc +++ b/src/core/lib/iomgr/udp_server.cc @@ -208,7 +208,7 @@ static grpc_socket_factory* get_socket_factory(const grpc_channel_args* args) { } grpc_udp_server* grpc_udp_server_create(const grpc_channel_args* args) { - grpc_udp_server* s = grpc_core::New(); + grpc_udp_server* s = new grpc_udp_server(); gpr_mu_init(&s->mu); s->socket_factory = get_socket_factory(args); if (s->socket_factory) { @@ -258,7 +258,7 @@ static void finish_shutdown(grpc_udp_server* s) { grpc_socket_factory_unref(s->socket_factory); } - grpc_core::Delete(s); + delete s; } static void destroyed_port(void* server, grpc_error* /*error*/) { diff --git a/src/core/lib/security/credentials/alts/alts_credentials.cc b/src/core/lib/security/credentials/alts/alts_credentials.cc index cbc43d565a4..1bc76d9c0c6 100644 --- a/src/core/lib/security/credentials/alts/alts_credentials.cc +++ b/src/core/lib/security/credentials/alts/alts_credentials.cc @@ -85,7 +85,7 @@ grpc_channel_credentials* grpc_alts_credentials_create_customized( if (!enable_untrusted_alts && !grpc_alts_is_running_on_gcp()) { return nullptr; } - return grpc_core::New(options, handshaker_service_url); + return new grpc_alts_credentials(options, handshaker_service_url); } grpc_server_credentials* grpc_alts_server_credentials_create_customized( @@ -94,8 +94,7 @@ grpc_server_credentials* grpc_alts_server_credentials_create_customized( if (!enable_untrusted_alts && !grpc_alts_is_running_on_gcp()) { return nullptr; } - return grpc_core::New(options, - handshaker_service_url); + return new grpc_alts_server_credentials(options, handshaker_service_url); } grpc_channel_credentials* grpc_alts_credentials_create( diff --git a/src/core/lib/security/credentials/composite/composite_credentials.cc b/src/core/lib/security/credentials/composite/composite_credentials.cc index 1e46798ff2c..d35a4c27359 100644 --- a/src/core/lib/security/credentials/composite/composite_credentials.cc +++ b/src/core/lib/security/credentials/composite/composite_credentials.cc @@ -90,7 +90,7 @@ bool grpc_composite_call_credentials::get_request_metadata( grpc_credentials_mdelem_array* md_array, grpc_closure* on_request_metadata, grpc_error** error) { grpc_composite_call_credentials_metadata_context* ctx; - ctx = grpc_core::New( + ctx = new grpc_composite_call_credentials_metadata_context( this, pollent, auth_md_context, md_array, on_request_metadata); bool synchronous = true; const CallCredentialsList& inner = ctx->composite_creds->inner(); @@ -104,7 +104,7 @@ bool grpc_composite_call_credentials::get_request_metadata( break; } } - if (synchronous) grpc_core::Delete(ctx); + if (synchronous) delete ctx; return synchronous; } @@ -205,6 +205,6 @@ grpc_channel_credentials* grpc_composite_channel_credentials_create( "grpc_composite_channel_credentials_create(channel_creds=%p, " "call_creds=%p, reserved=%p)", 3, (channel_creds, call_creds, reserved)); - return grpc_core::New( - channel_creds->Ref(), call_creds->Ref()); + return new grpc_composite_channel_credentials(channel_creds->Ref(), + call_creds->Ref()); } diff --git a/src/core/lib/security/credentials/credentials.cc b/src/core/lib/security/credentials/credentials.cc index 37678715704..8ef58d2a4b4 100644 --- a/src/core/lib/security/credentials/credentials.cc +++ b/src/core/lib/security/credentials/credentials.cc @@ -53,10 +53,10 @@ static gpr_mu g_control_plane_creds_mu; static void do_control_plane_creds_init() { gpr_mu_init(&g_control_plane_creds_mu); GPR_ASSERT(g_grpc_control_plane_creds == nullptr); - g_grpc_control_plane_creds = grpc_core::New< - std::map, - grpc_core::RefCountedPtr, - grpc_core::StringLess>>(); + g_grpc_control_plane_creds = + new std::map, + grpc_core::RefCountedPtr, + grpc_core::StringLess>(); } void grpc_control_plane_credentials_init() { @@ -65,7 +65,7 @@ void grpc_control_plane_credentials_init() { } void grpc_test_only_control_plane_credentials_destroy() { - grpc_core::Delete(g_grpc_control_plane_creds); + delete g_grpc_control_plane_creds; g_grpc_control_plane_creds = nullptr; gpr_mu_destroy(&g_control_plane_creds_mu); } diff --git a/src/core/lib/security/credentials/credentials.h b/src/core/lib/security/credentials/credentials.h index e0700c41a92..4518f013e1b 100644 --- a/src/core/lib/security/credentials/credentials.h +++ b/src/core/lib/security/credentials/credentials.h @@ -314,12 +314,12 @@ struct grpc_credentials_metadata_request { inline grpc_credentials_metadata_request* grpc_credentials_metadata_request_create( grpc_core::RefCountedPtr creds) { - return grpc_core::New(std::move(creds)); + return new grpc_credentials_metadata_request(std::move(creds)); } inline void grpc_credentials_metadata_request_destroy( grpc_credentials_metadata_request* r) { - grpc_core::Delete(r); + delete r; } #endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_CREDENTIALS_H */ diff --git a/src/core/lib/security/credentials/fake/fake_credentials.cc b/src/core/lib/security/credentials/fake/fake_credentials.cc index 77aed2c1b9d..8fd0493ee44 100644 --- a/src/core/lib/security/credentials/fake/fake_credentials.cc +++ b/src/core/lib/security/credentials/fake/fake_credentials.cc @@ -66,12 +66,12 @@ class grpc_fake_server_credentials final : public grpc_server_credentials { } // namespace grpc_channel_credentials* grpc_fake_transport_security_credentials_create() { - return grpc_core::New(); + return new grpc_fake_channel_credentials(); } grpc_server_credentials* grpc_fake_transport_security_server_credentials_create() { - return grpc_core::New(); + return new grpc_fake_server_credentials(); } grpc_arg grpc_fake_transport_expected_targets_arg(char* expected_targets) { @@ -108,6 +108,5 @@ void grpc_md_only_test_credentials::cancel_get_request_metadata( grpc_call_credentials* grpc_md_only_test_credentials_create( const char* md_key, const char* md_value, bool is_async) { - return grpc_core::New(md_key, md_value, - is_async); + return new grpc_md_only_test_credentials(md_key, md_value, is_async); } diff --git a/src/core/lib/security/credentials/local/local_credentials.cc b/src/core/lib/security/credentials/local/local_credentials.cc index 9977cae050d..966a887baf8 100644 --- a/src/core/lib/security/credentials/local/local_credentials.cc +++ b/src/core/lib/security/credentials/local/local_credentials.cc @@ -50,7 +50,7 @@ grpc_local_credentials::grpc_local_credentials( grpc_channel_credentials* grpc_local_credentials_create( grpc_local_connect_type connect_type) { - return grpc_core::New(connect_type); + return new grpc_local_credentials(connect_type); } grpc_local_server_credentials::grpc_local_server_credentials( @@ -60,5 +60,5 @@ grpc_local_server_credentials::grpc_local_server_credentials( grpc_server_credentials* grpc_local_server_credentials_create( grpc_local_connect_type connect_type) { - return grpc_core::New(connect_type); + return new grpc_local_server_credentials(connect_type); } diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc index 1c6ea9388b0..895776c27f0 100644 --- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc @@ -643,7 +643,7 @@ grpc_error* ValidateStsCredentialsOptions( }; *sts_url_out = nullptr; InlinedVector error_list; - UniquePtr sts_url( + std::unique_ptr sts_url( options->token_exchange_service_uri != nullptr ? grpc_uri_parse(options->token_exchange_service_uri, false) : nullptr); diff --git a/src/core/lib/security/credentials/plugin/plugin_credentials.cc b/src/core/lib/security/credentials/plugin/plugin_credentials.cc index d74f77282a2..517bf277f37 100644 --- a/src/core/lib/security/credentials/plugin/plugin_credentials.cc +++ b/src/core/lib/security/credentials/plugin/plugin_credentials.cc @@ -250,5 +250,5 @@ grpc_call_credentials* grpc_metadata_credentials_create_from_plugin( GRPC_API_TRACE("grpc_metadata_credentials_create_from_plugin(reserved=%p)", 1, (reserved)); GPR_ASSERT(reserved == nullptr); - return grpc_core::New(plugin); + return new grpc_plugin_credentials(plugin); } diff --git a/src/core/lib/security/credentials/ssl/ssl_credentials.cc b/src/core/lib/security/credentials/ssl/ssl_credentials.cc index 65e57cebeb5..48d78f39583 100644 --- a/src/core/lib/security/credentials/ssl/ssl_credentials.cc +++ b/src/core/lib/security/credentials/ssl/ssl_credentials.cc @@ -130,7 +130,7 @@ grpc_channel_credentials* grpc_ssl_credentials_create( 4, (pem_root_certs, pem_key_cert_pair, verify_options, reserved)); GPR_ASSERT(reserved == nullptr); - return grpc_core::New( + return new grpc_ssl_credentials( pem_root_certs, pem_key_cert_pair, reinterpret_cast(verify_options)); } @@ -146,8 +146,8 @@ grpc_channel_credentials* grpc_ssl_credentials_create_ex( 4, (pem_root_certs, pem_key_cert_pair, verify_options, reserved)); GPR_ASSERT(reserved == nullptr); - return grpc_core::New(pem_root_certs, pem_key_cert_pair, - verify_options); + return new grpc_ssl_credentials(pem_root_certs, pem_key_cert_pair, + verify_options); } // @@ -348,7 +348,7 @@ grpc_server_credentials* grpc_ssl_server_credentials_create_with_options( goto done; } - retval = grpc_core::New(*options); + retval = new grpc_ssl_server_credentials(*options); done: grpc_ssl_server_credentials_options_destroy(options); diff --git a/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc b/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc index 7e0af3dcc17..199a15b6354 100644 --- a/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +++ b/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc @@ -76,7 +76,7 @@ grpc_tls_server_authorization_check_config:: /** -- Wrapper APIs declared in grpc_security.h -- **/ grpc_tls_credentials_options* grpc_tls_credentials_options_create() { - return grpc_core::New(); + return new grpc_tls_credentials_options(); } int grpc_tls_credentials_options_set_cert_request_type( @@ -133,7 +133,7 @@ int grpc_tls_credentials_options_set_server_authorization_check_config( } grpc_tls_key_materials_config* grpc_tls_key_materials_config_create() { - return grpc_core::New(); + return new grpc_tls_key_materials_config(); } int grpc_tls_key_materials_config_set_key_materials( @@ -192,8 +192,8 @@ grpc_tls_credential_reload_config* grpc_tls_credential_reload_config_create( "Schedule API is nullptr in creating TLS credential reload config."); return nullptr; } - return grpc_core::New( - config_user_data, schedule, cancel, destruct); + return new grpc_tls_credential_reload_config(config_user_data, schedule, + cancel, destruct); } grpc_tls_server_authorization_check_config* @@ -210,6 +210,6 @@ grpc_tls_server_authorization_check_config_create( "check config."); return nullptr; } - return grpc_core::New( + return new grpc_tls_server_authorization_check_config( config_user_data, schedule, cancel, destruct); } diff --git a/src/core/lib/security/credentials/tls/spiffe_credentials.cc b/src/core/lib/security/credentials/tls/spiffe_credentials.cc index e8433bf09b8..078bc578a4f 100644 --- a/src/core/lib/security/credentials/tls/spiffe_credentials.cc +++ b/src/core/lib/security/credentials/tls/spiffe_credentials.cc @@ -115,7 +115,7 @@ grpc_channel_credentials* grpc_tls_spiffe_credentials_create( if (!CredentialOptionSanityCheck(options, true /* is_client */)) { return nullptr; } - return grpc_core::New( + return new SpiffeCredentials( grpc_core::RefCountedPtr(options)); } @@ -124,6 +124,6 @@ grpc_server_credentials* grpc_tls_spiffe_server_credentials_create( if (!CredentialOptionSanityCheck(options, false /* is_client */)) { return nullptr; } - return grpc_core::New( + return new SpiffeServerCredentials( grpc_core::RefCountedPtr(options)); } diff --git a/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc b/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc index 12fd15f6a58..a388f9d5739 100644 --- a/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc +++ b/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc @@ -80,8 +80,7 @@ grpc_status_code TlsFetchKeyMaterials( grpc_status_code status = GRPC_STATUS_OK; /* Use credential reload config to fetch credentials. */ if (options.credential_reload_config() != nullptr) { - grpc_tls_credential_reload_arg* arg = - grpc_core::New(); + grpc_tls_credential_reload_arg* arg = new grpc_tls_credential_reload_arg(); arg->key_materials_config = key_materials_config.get(); int result = options.credential_reload_config()->Schedule(arg); if (result) { @@ -107,7 +106,7 @@ grpc_status_code TlsFetchKeyMaterials( if (arg->destroy_context != nullptr) { arg->destroy_context(arg->context); } - grpc_core::Delete(arg); + delete arg; } return status; } @@ -381,7 +380,7 @@ grpc_tls_server_authorization_check_arg* SpiffeChannelSecurityConnector::ServerAuthorizationCheckArgCreate( void* user_data) { grpc_tls_server_authorization_check_arg* arg = - grpc_core::New(); + new grpc_tls_server_authorization_check_arg(); arg->cb = ServerAuthorizationCheckDone; arg->cb_user_data = user_data; arg->status = GRPC_STATUS_OK; @@ -399,7 +398,7 @@ void SpiffeChannelSecurityConnector::ServerAuthorizationCheckArgDestroy( if (arg->destroy_context != nullptr) { arg->destroy_context(arg->context); } - grpc_core::Delete(arg); + delete arg; } SpiffeServerSecurityConnector::SpiffeServerSecurityConnector( diff --git a/src/core/lib/security/transport/secure_endpoint.cc b/src/core/lib/security/transport/secure_endpoint.cc index 705d1675615..eaa8c7da704 100644 --- a/src/core/lib/security/transport/secure_endpoint.cc +++ b/src/core/lib/security/transport/secure_endpoint.cc @@ -104,7 +104,7 @@ struct secure_endpoint { grpc_core::TraceFlag grpc_trace_secure_endpoint(false, "secure_endpoint"); -static void destroy(secure_endpoint* ep) { grpc_core::Delete(ep); } +static void destroy(secure_endpoint* ep) { delete ep; } #ifndef NDEBUG #define SECURE_ENDPOINT_UNREF(ep, reason) \ @@ -439,8 +439,8 @@ grpc_endpoint* grpc_secure_endpoint_create( struct tsi_zero_copy_grpc_protector* zero_copy_protector, grpc_endpoint* transport, grpc_slice* leftover_slices, size_t leftover_nslices) { - secure_endpoint* ep = grpc_core::New( - &vtable, protector, zero_copy_protector, transport, leftover_slices, - leftover_nslices); + secure_endpoint* ep = + new secure_endpoint(&vtable, protector, zero_copy_protector, transport, + leftover_slices, leftover_nslices); return &ep->base; } diff --git a/src/core/lib/slice/slice.cc b/src/core/lib/slice/slice.cc index a3936a8d2e3..c0e21648f74 100644 --- a/src/core/lib/slice/slice.cc +++ b/src/core/lib/slice/slice.cc @@ -73,9 +73,7 @@ static_assert(std::is_trivially_destructible::value, with the user provided data pointer & destroy function */ class NewSliceRefcount { public: - static void Destroy(void* arg) { - Delete(static_cast(arg)); - } + static void Destroy(void* arg) { delete static_cast(arg); } NewSliceRefcount(void (*destroy)(void*), void* user_data) : base_(grpc_slice_refcount::Type::REGULAR, &refs_, Destroy, this, @@ -116,8 +114,7 @@ grpc_slice grpc_slice_new_with_user_data(void* p, size_t len, void* user_data) { grpc_slice slice; slice.refcount = - grpc_core::New(destroy, user_data) - ->base_refcount(); + (new grpc_core::NewSliceRefcount(destroy, user_data))->base_refcount(); slice.data.refcounted.bytes = static_cast(p); slice.data.refcounted.length = len; return slice; @@ -134,7 +131,7 @@ namespace grpc_core { class NewWithLenSliceRefcount { public: static void Destroy(void* arg) { - Delete(static_cast(arg)); + delete static_cast(arg); } NewWithLenSliceRefcount(void (*destroy)(void*, size_t), void* user_data, @@ -168,7 +165,7 @@ class MovedStringSliceRefCount { private: static void Destroy(void* arg) { - Delete(static_cast(arg)); + delete static_cast(arg); } grpc_slice_refcount base_; @@ -181,9 +178,8 @@ class MovedStringSliceRefCount { grpc_slice grpc_slice_new_with_len(void* p, size_t len, void (*destroy)(void*, size_t)) { grpc_slice slice; - slice.refcount = - grpc_core::New(destroy, p, len) - ->base_refcount(); + slice.refcount = (new grpc_core::NewWithLenSliceRefcount(destroy, p, len)) + ->base_refcount(); slice.data.refcounted.bytes = static_cast(p); slice.data.refcounted.length = len; return slice; @@ -223,9 +219,8 @@ grpc_slice grpc_slice_from_moved_buffer(grpc_core::UniquePtr p, slice.data.inlined.length = len; memcpy(GRPC_SLICE_START_PTR(slice), ptr, len); } else { - slice.refcount = - grpc_core::New(std::move(p)) - ->base_refcount(); + slice.refcount = (new grpc_core::MovedStringSliceRefCount(std::move(p))) + ->base_refcount(); slice.data.refcounted.bytes = ptr; slice.data.refcounted.length = len; } diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc index f3848fd4ffa..33ea56b62ce 100644 --- a/src/core/lib/surface/server.cc +++ b/src/core/lib/surface/server.cc @@ -1249,8 +1249,7 @@ void grpc_server_setup_transport( op->set_accept_stream = true; op->set_accept_stream_fn = accept_stream; op->set_accept_stream_user_data = chand; - op->start_connectivity_watch.reset( - grpc_core::New(chand)); + op->start_connectivity_watch.reset(new ConnectivityWatcher(chand)); if (gpr_atm_acq_load(&s->shutdown_flag) != 0) { op->disconnect_with_error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Server shutdown"); diff --git a/src/core/lib/transport/connectivity_state.cc b/src/core/lib/transport/connectivity_state.cc index d8b8022aae1..16da01d041c 100644 --- a/src/core/lib/transport/connectivity_state.cc +++ b/src/core/lib/transport/connectivity_state.cc @@ -79,7 +79,7 @@ class AsyncConnectivityStateWatcherInterface::Notifier { self->watcher_.get(), ConnectivityStateName(self->state_)); } self->watcher_->OnConnectivityStateChange(self->state_); - Delete(self); + delete self; } RefCountedPtr watcher_; @@ -89,7 +89,7 @@ class AsyncConnectivityStateWatcherInterface::Notifier { void AsyncConnectivityStateWatcherInterface::Notify( grpc_connectivity_state state) { - New(Ref(), state, combiner_); // Deletes itself when done. + new Notifier(Ref(), state, combiner_); // Deletes itself when done. } // diff --git a/src/core/lib/transport/metadata.cc b/src/core/lib/transport/metadata.cc index 76017207d47..9a6645cf57f 100644 --- a/src/core/lib/transport/metadata.cc +++ b/src/core/lib/transport/metadata.cc @@ -207,7 +207,7 @@ size_t InternedMetadata::CleanupLinkedMetadata( next = md->link_.next; if (md->AllRefsDropped()) { prev_next->next = next; - grpc_core::Delete(md); + delete md; num_freed++; } else { prev_next = &md->link_; @@ -373,14 +373,13 @@ static grpc_mdelem md_create( // We allocate backing store. return key_definitely_static ? GRPC_MAKE_MDELEM( - grpc_core::New( + new AllocatedMetadata( key, value, static_cast( nullptr)), GRPC_MDELEM_STORAGE_ALLOCATED) - : GRPC_MAKE_MDELEM( - grpc_core::New(key, value), - GRPC_MDELEM_STORAGE_ALLOCATED); + : GRPC_MAKE_MDELEM(new AllocatedMetadata(key, value), + GRPC_MDELEM_STORAGE_ALLOCATED); } } return md_create_maybe_static( @@ -456,11 +455,10 @@ static grpc_mdelem md_create_must_intern(const grpc_slice& key, /* not found: create a new pair */ md = key_definitely_static - ? grpc_core::New( + ? new InternedMetadata( key, value, hash, shard->elems[idx].next, static_cast(nullptr)) - : grpc_core::New(key, value, hash, - shard->elems[idx].next); + : new InternedMetadata(key, value, hash, shard->elems[idx].next); shard->elems[idx].next = md; shard->count++; @@ -656,7 +654,7 @@ void grpc_mdelem_do_unref(grpc_mdelem gmd DEBUG_ARGS) { case GRPC_MDELEM_STORAGE_ALLOCATED: { auto* md = reinterpret_cast GRPC_MDELEM_DATA(gmd); if (GPR_UNLIKELY(md->Unref(FWD_DEBUG_ARGS))) { - grpc_core::Delete(md); + delete md; } break; } @@ -674,7 +672,7 @@ void grpc_mdelem_on_final_unref(grpc_mdelem_data_storage storage, void* ptr, break; } case GRPC_MDELEM_STORAGE_ALLOCATED: { - grpc_core::Delete(reinterpret_cast(ptr)); + delete reinterpret_cast(ptr); break; } } diff --git a/src/core/lib/transport/metadata.h b/src/core/lib/transport/metadata.h index 9631df3c1a2..4bb8d64dd03 100644 --- a/src/core/lib/transport/metadata.h +++ b/src/core/lib/transport/metadata.h @@ -423,7 +423,7 @@ inline grpc_mdelem grpc_mdelem_from_slices( const grpc_core::ManagedMemorySlice& key, const grpc_core::UnmanagedMemorySlice& value) { using grpc_core::AllocatedMetadata; - return GRPC_MAKE_MDELEM(grpc_core::New(key, value), + return GRPC_MAKE_MDELEM(new AllocatedMetadata(key, value), GRPC_MDELEM_STORAGE_ALLOCATED); } @@ -431,7 +431,7 @@ inline grpc_mdelem grpc_mdelem_from_slices( const grpc_core::ExternallyManagedSlice& key, const grpc_core::UnmanagedMemorySlice& value) { using grpc_core::AllocatedMetadata; - return GRPC_MAKE_MDELEM(grpc_core::New(key, value), + return GRPC_MAKE_MDELEM(new AllocatedMetadata(key, value), GRPC_MDELEM_STORAGE_ALLOCATED); } @@ -439,7 +439,7 @@ inline grpc_mdelem grpc_mdelem_from_slices( const grpc_core::StaticMetadataSlice& key, const grpc_core::UnmanagedMemorySlice& value) { using grpc_core::AllocatedMetadata; - return GRPC_MAKE_MDELEM(grpc_core::New(key, value), + return GRPC_MAKE_MDELEM(new AllocatedMetadata(key, value), GRPC_MDELEM_STORAGE_ALLOCATED); } diff --git a/src/core/lib/transport/static_metadata.cc b/src/core/lib/transport/static_metadata.cc index a86ab002309..0aa3296122e 100644 --- a/src/core/lib/transport/static_metadata.cc +++ b/src/core/lib/transport/static_metadata.cc @@ -1149,8 +1149,7 @@ uint64_t StaticMetadataInitCanary() { } // namespace grpc_core void grpc_init_static_metadata_ctx(void) { - grpc_core::g_static_metadata_slice_ctx = - grpc_core::New(); + grpc_core::g_static_metadata_slice_ctx = new grpc_core::StaticMetadataCtx(); grpc_core::g_static_metadata_slice_table = grpc_core::g_static_metadata_slice_ctx->slices; grpc_core::g_static_metadata_slice_refcounts = @@ -1162,8 +1161,7 @@ void grpc_init_static_metadata_ctx(void) { } void grpc_destroy_static_metadata_ctx(void) { - grpc_core::Delete( - grpc_core::g_static_metadata_slice_ctx); + delete grpc_core::g_static_metadata_slice_ctx; grpc_core::g_static_metadata_slice_ctx = nullptr; grpc_core::g_static_metadata_slice_table = nullptr; grpc_core::g_static_metadata_slice_refcounts = nullptr; diff --git a/src/core/lib/transport/transport.cc b/src/core/lib/transport/transport.cc index f691074cf67..2763aeecb90 100644 --- a/src/core/lib/transport/transport.cc +++ b/src/core/lib/transport/transport.cc @@ -221,11 +221,11 @@ static void destroy_made_transport_op(void* arg, grpc_error* error) { made_transport_op* op = static_cast(arg); grpc_core::ExecCtx::Run(DEBUG_LOCATION, op->inner_on_complete, GRPC_ERROR_REF(error)); - grpc_core::Delete(op); + delete op; } grpc_transport_op* grpc_make_transport_op(grpc_closure* on_complete) { - made_transport_op* op = grpc_core::New(); + made_transport_op* op = new made_transport_op(); GRPC_CLOSURE_INIT(&op->outer_on_complete, destroy_made_transport_op, op, grpc_schedule_on_exec_ctx); op->inner_on_complete = on_complete; diff --git a/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc b/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc index edd95c38386..468ec36ed7d 100644 --- a/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +++ b/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc @@ -378,7 +378,7 @@ static void alts_tsi_handshaker_create_channel(void* arg, next_args->cb(continue_next_result, next_args->user_data, nullptr, 0, nullptr); } - grpc_core::Delete(next_args); + delete next_args; } static tsi_result handshaker_next( @@ -401,7 +401,7 @@ static tsi_result handshaker_next( } if (handshaker->channel == nullptr && !handshaker->use_dedicated_cq) { alts_tsi_handshaker_continue_handshaker_next_args* args = - grpc_core::New(); + new alts_tsi_handshaker_continue_handshaker_next_args(); args->handshaker = handshaker; args->received_bytes = nullptr; args->received_bytes_size = received_bytes_size; diff --git a/src/core/tsi/ssl/session_cache/ssl_session_cache.cc b/src/core/tsi/ssl/session_cache/ssl_session_cache.cc index 8e3a78f6393..0fd5aa9ce16 100644 --- a/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +++ b/src/core/tsi/ssl/session_cache/ssl_session_cache.cc @@ -92,7 +92,7 @@ SslSessionLRUCache::~SslSessionLRUCache() { Node* node = use_order_list_head_; while (node) { Node* next = node->next_; - grpc_core::Delete(node); + delete node; node = next; } grpc_avl_unref(entry_by_key_, nullptr); @@ -127,7 +127,7 @@ void SslSessionLRUCache::Put(const char* key, SslSessionPtr session) { return; } grpc_slice key_slice = grpc_slice_from_copied_string(key); - node = grpc_core::New(key_slice, std::move(session)); + node = new Node(key_slice, std::move(session)); PushFront(node); entry_by_key_ = grpc_avl_add(entry_by_key_, node->AvlKey(), node, nullptr); AssertInvariants(); @@ -137,7 +137,7 @@ void SslSessionLRUCache::Put(const char* key, SslSessionPtr session) { Remove(node); // Order matters, key is destroyed after deleting node. entry_by_key_ = grpc_avl_remove(entry_by_key_, node->AvlKey(), nullptr); - grpc_core::Delete(node); + delete node; AssertInvariants(); } } diff --git a/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm b/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm index b0929074c3d..32db8da9fb4 100644 --- a/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm +++ b/src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm @@ -59,7 +59,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( grpc_channel_args *client_args, grpc_channel_args *server_args) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_secure_fixture_data *ffd = grpc_core::New(); + fullstack_secure_fixture_data *ffd = new fullstack_secure_fixture_data(); memset(&f, 0, sizeof(f)); grpc_core::JoinHostPort(&ffd->localaddr, "127.0.0.1", port); diff --git a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc index 549255fbf01..564a4339ea4 100644 --- a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc +++ b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc @@ -167,7 +167,7 @@ int main(int argc, char** argv) { { grpc_core::ExecCtx exec_ctx; - ResultHandler* result_handler = grpc_core::New(); + ResultHandler* result_handler = new ResultHandler(); grpc_core::OrphanablePtr resolver = create_resolver( "dns:test", grpc_core::UniquePtr( result_handler)); diff --git a/test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc b/test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc index 5eb42b09c53..35f45c59216 100644 --- a/test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc +++ b/test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc @@ -230,7 +230,7 @@ static void on_fourth_resolution(OnResolutionCallbackArg* cb_arg) { GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_iomgr_args.pollset, nullptr)); gpr_mu_unlock(g_iomgr_args.mu); - grpc_core::Delete(cb_arg); + delete cb_arg; g_all_callbacks_invoked = true; } @@ -274,7 +274,7 @@ static void on_first_resolution(OnResolutionCallbackArg* cb_arg) { static void start_test_under_combiner(void* arg, grpc_error* /*error*/) { OnResolutionCallbackArg* res_cb_arg = static_cast(arg); - res_cb_arg->result_handler = grpc_core::New(); + res_cb_arg->result_handler = new ResultHandler(); grpc_core::ResolverFactory* factory = grpc_core::ResolverRegistry::LookupResolverFactory("dns"); grpc_uri* uri = grpc_uri_parse(res_cb_arg->uri_str, 0); @@ -305,8 +305,7 @@ static void start_test_under_combiner(void* arg, grpc_error* /*error*/) { static void test_cooldown() { grpc_core::ExecCtx exec_ctx; iomgr_args_init(&g_iomgr_args); - OnResolutionCallbackArg* res_cb_arg = - grpc_core::New(); + OnResolutionCallbackArg* res_cb_arg = new OnResolutionCallbackArg(); res_cb_arg->uri_str = "dns:127.0.0.1"; g_combiner->Run( diff --git a/test/core/client_channel/resolvers/fake_resolver_test.cc b/test/core/client_channel/resolvers/fake_resolver_test.cc index 6bfe953b8ae..cdb4fa41bc8 100644 --- a/test/core/client_channel/resolvers/fake_resolver_test.cc +++ b/test/core/client_channel/resolvers/fake_resolver_test.cc @@ -120,7 +120,7 @@ static void test_fake_resolver() { grpc_core::ExecCtx exec_ctx; grpc_core::Combiner* combiner = grpc_combiner_create(); // Create resolver. - ResultHandler* result_handler = grpc_core::New(); + ResultHandler* result_handler = new ResultHandler(); grpc_core::RefCountedPtr response_generator = grpc_core::MakeRefCounted(); diff --git a/test/core/end2end/bad_server_response_test.cc b/test/core/end2end/bad_server_response_test.cc index 6bc13d675f6..09c503e1e85 100644 --- a/test/core/end2end/bad_server_response_test.cc +++ b/test/core/end2end/bad_server_response_test.cc @@ -264,8 +264,8 @@ static grpc_core::Thread* poll_server_until_read_done( poll_args* pa = static_cast(gpr_malloc(sizeof(*pa))); pa->server = server; pa->signal_when_done = signal_when_done; - auto* th = grpc_core::New("grpc_poll_server", - actually_poll_server, pa); + auto* th = + new grpc_core::Thread("grpc_poll_server", actually_poll_server, pa); th->Start(); return th; } diff --git a/test/core/end2end/fixtures/h2_census.cc b/test/core/end2end/fixtures/h2_census.cc index 69f11c593df..afabae10966 100644 --- a/test/core/end2end/fixtures/h2_census.cc +++ b/test/core/end2end/fixtures/h2_census.cc @@ -43,7 +43,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_fixture_data* ffd = grpc_core::New(); + fullstack_fixture_data* ffd = new fullstack_fixture_data(); memset(&f, 0, sizeof(f)); grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); @@ -100,7 +100,7 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); - grpc_core::Delete(ffd); + delete ffd; } /* All test configurations */ diff --git a/test/core/end2end/fixtures/h2_compress.cc b/test/core/end2end/fixtures/h2_compress.cc index 8492cba87cd..a0a7c298234 100644 --- a/test/core/end2end/fixtures/h2_compress.cc +++ b/test/core/end2end/fixtures/h2_compress.cc @@ -51,7 +51,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_compression( grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); fullstack_compression_fixture_data* ffd = - grpc_core::New(); + new fullstack_compression_fixture_data(); grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); memset(&f, 0, sizeof(f)); @@ -102,7 +102,7 @@ void chttp2_tear_down_fullstack_compression(grpc_end2end_test_fixture* f) { grpc_core::ExecCtx exec_ctx; fullstack_compression_fixture_data* ffd = static_cast(f->fixture_data); - grpc_core::Delete(ffd); + delete ffd; } /* All test configurations */ diff --git a/test/core/end2end/fixtures/h2_fakesec.cc b/test/core/end2end/fixtures/h2_fakesec.cc index 130c04bb151..d8d92bea3b5 100644 --- a/test/core/end2end/fixtures/h2_fakesec.cc +++ b/test/core/end2end/fixtures/h2_fakesec.cc @@ -39,8 +39,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_secure_fixture_data* ffd = - grpc_core::New(); + fullstack_secure_fixture_data* ffd = new fullstack_secure_fixture_data(); memset(&f, 0, sizeof(f)); grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); @@ -90,7 +89,7 @@ static void chttp2_init_server_secure_fullstack( void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - grpc_core::Delete(ffd); + delete ffd; } static void chttp2_init_client_fake_secure_fullstack( diff --git a/test/core/end2end/fixtures/h2_full+pipe.cc b/test/core/end2end/fixtures/h2_full+pipe.cc index 609a8e66da8..a9807e620de 100644 --- a/test/core/end2end/fixtures/h2_full+pipe.cc +++ b/test/core/end2end/fixtures/h2_full+pipe.cc @@ -48,7 +48,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_fixture_data* ffd = grpc_core::New(); + fullstack_fixture_data* ffd = new fullstack_fixture_data(); memset(&f, 0, sizeof(f)); grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); @@ -86,7 +86,7 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); - grpc_core::Delete(ffd); + delete ffd; } /* All test configurations */ diff --git a/test/core/end2end/fixtures/h2_full+trace.cc b/test/core/end2end/fixtures/h2_full+trace.cc index 7405f613bdd..64fdca78a4a 100644 --- a/test/core/end2end/fixtures/h2_full+trace.cc +++ b/test/core/end2end/fixtures/h2_full+trace.cc @@ -48,7 +48,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_fixture_data* ffd = grpc_core::New(); + fullstack_fixture_data* ffd = new fullstack_fixture_data(); memset(&f, 0, sizeof(f)); grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); @@ -86,7 +86,7 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); - grpc_core::Delete(ffd); + delete ffd; } /* All test configurations */ diff --git a/test/core/end2end/fixtures/h2_full+workarounds.cc b/test/core/end2end/fixtures/h2_full+workarounds.cc index e4ced484c5e..d524175925a 100644 --- a/test/core/end2end/fixtures/h2_full+workarounds.cc +++ b/test/core/end2end/fixtures/h2_full+workarounds.cc @@ -47,7 +47,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_fixture_data* ffd = grpc_core::New(); + fullstack_fixture_data* ffd = new fullstack_fixture_data(); memset(&f, 0, sizeof(f)); grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; @@ -93,7 +93,7 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); - grpc_core::Delete(ffd); + delete ffd; } /* All test configurations */ diff --git a/test/core/end2end/fixtures/h2_full.cc b/test/core/end2end/fixtures/h2_full.cc index 4b42c13f5e7..485c792162c 100644 --- a/test/core/end2end/fixtures/h2_full.cc +++ b/test/core/end2end/fixtures/h2_full.cc @@ -42,7 +42,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_fixture_data* ffd = grpc_core::New(); + fullstack_fixture_data* ffd = new fullstack_fixture_data(); memset(&f, 0, sizeof(f)); grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); @@ -80,7 +80,7 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); - grpc_core::Delete(ffd); + delete ffd; } /* All test configurations */ diff --git a/test/core/end2end/fixtures/h2_http_proxy.cc b/test/core/end2end/fixtures/h2_http_proxy.cc index e1158146004..e88042d57fb 100644 --- a/test/core/end2end/fixtures/h2_http_proxy.cc +++ b/test/core/end2end/fixtures/h2_http_proxy.cc @@ -47,7 +47,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( grpc_channel_args* client_args, grpc_channel_args* /*server_args*/) { grpc_end2end_test_fixture f; memset(&f, 0, sizeof(f)); - fullstack_fixture_data* ffd = grpc_core::New(); + fullstack_fixture_data* ffd = new fullstack_fixture_data(); const int server_port = grpc_pick_unused_port_or_die(); grpc_core::JoinHostPort(&ffd->server_addr, "localhost", server_port); @@ -103,7 +103,7 @@ void chttp2_init_server_fullstack(grpc_end2end_test_fixture* f, void chttp2_tear_down_fullstack(grpc_end2end_test_fixture* f) { fullstack_fixture_data* ffd = static_cast(f->fixture_data); - grpc_core::Delete(ffd); + delete ffd; } /* All test configurations */ diff --git a/test/core/end2end/fixtures/h2_oauth2.cc b/test/core/end2end/fixtures/h2_oauth2.cc index 440a5fd24fc..0800d5929f2 100644 --- a/test/core/end2end/fixtures/h2_oauth2.cc +++ b/test/core/end2end/fixtures/h2_oauth2.cc @@ -94,8 +94,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_secure_fixture_data* ffd = - grpc_core::New(); + fullstack_secure_fixture_data* ffd = new fullstack_secure_fixture_data(); memset(&f, 0, sizeof(f)); grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; @@ -134,7 +133,7 @@ static void chttp2_init_server_secure_fullstack( void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - grpc_core::Delete(ffd); + delete ffd; } static void chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack( diff --git a/test/core/end2end/fixtures/h2_spiffe.cc b/test/core/end2end/fixtures/h2_spiffe.cc index 21df3b54531..306e94fd1b2 100644 --- a/test/core/end2end/fixtures/h2_spiffe.cc +++ b/test/core/end2end/fixtures/h2_spiffe.cc @@ -56,8 +56,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_secure_fixture_data* ffd = - grpc_core::New(); + fullstack_secure_fixture_data* ffd = new fullstack_secure_fixture_data(); memset(&f, 0, sizeof(f)); grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; @@ -105,7 +104,7 @@ static void chttp2_init_server_secure_fullstack( void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - grpc_core::Delete(ffd); + delete ffd; } // Application-provided callback for server authorization check. diff --git a/test/core/end2end/fixtures/h2_ssl.cc b/test/core/end2end/fixtures/h2_ssl.cc index f0bc469f337..2ba2418151d 100644 --- a/test/core/end2end/fixtures/h2_ssl.cc +++ b/test/core/end2end/fixtures/h2_ssl.cc @@ -42,8 +42,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_secure_fixture_data* ffd = - grpc_core::New(); + fullstack_secure_fixture_data* ffd = new fullstack_secure_fixture_data(); memset(&f, 0, sizeof(f)); grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); @@ -94,7 +93,7 @@ static void chttp2_init_server_secure_fullstack( void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - grpc_core::Delete(ffd); + delete ffd; } static void chttp2_init_client_simple_ssl_secure_fullstack( diff --git a/test/core/end2end/fixtures/h2_ssl_cred_reload.cc b/test/core/end2end/fixtures/h2_ssl_cred_reload.cc index d1fc1dccd4b..97600990230 100644 --- a/test/core/end2end/fixtures/h2_ssl_cred_reload.cc +++ b/test/core/end2end/fixtures/h2_ssl_cred_reload.cc @@ -63,8 +63,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_secure_fixture_data* ffd = - grpc_core::New(); + fullstack_secure_fixture_data* ffd = new fullstack_secure_fixture_data(); memset(&f, 0, sizeof(f)); grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); @@ -115,7 +114,7 @@ static void chttp2_init_server_secure_fullstack( void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - grpc_core::Delete(ffd); + delete ffd; } static void chttp2_init_client_simple_ssl_secure_fullstack( diff --git a/test/core/end2end/fixtures/http_proxy_fixture.cc b/test/core/end2end/fixtures/http_proxy_fixture.cc index 90e16dc43c8..de8cec386d4 100644 --- a/test/core/end2end/fixtures/http_proxy_fixture.cc +++ b/test/core/end2end/fixtures/http_proxy_fixture.cc @@ -609,7 +609,7 @@ static void thread_main(void* arg) { grpc_end2end_http_proxy* grpc_end2end_http_proxy_create( grpc_channel_args* args) { grpc_core::ExecCtx exec_ctx; - grpc_end2end_http_proxy* proxy = grpc_core::New(); + grpc_end2end_http_proxy* proxy = new grpc_end2end_http_proxy(); // Construct proxy address. const int proxy_port = grpc_pick_unused_port_or_die(); grpc_core::JoinHostPort(&proxy->proxy_name, "localhost", proxy_port); @@ -658,7 +658,7 @@ void grpc_end2end_http_proxy_destroy(grpc_end2end_http_proxy* proxy) { GRPC_CLOSURE_CREATE(destroy_pollset, proxy->pollset, grpc_schedule_on_exec_ctx)); GRPC_COMBINER_UNREF(proxy->combiner, "test"); - grpc_core::Delete(proxy); + delete proxy; } const char* grpc_end2end_http_proxy_get_proxy_name( diff --git a/test/core/end2end/fixtures/local_util.cc b/test/core/end2end/fixtures/local_util.cc index c1fd88b67b0..fadf80caf4f 100644 --- a/test/core/end2end/fixtures/local_util.cc +++ b/test/core/end2end/fixtures/local_util.cc @@ -36,7 +36,7 @@ grpc_end2end_test_fixture grpc_end2end_local_chttp2_create_fixture_fullstack() { grpc_end2end_test_fixture f; grpc_end2end_local_fullstack_fixture_data* ffd = - grpc_core::New(); + new grpc_end2end_local_fullstack_fixture_data(); memset(&f, 0, sizeof(f)); f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(nullptr); @@ -108,5 +108,5 @@ void grpc_end2end_local_chttp2_tear_down_fullstack( grpc_end2end_test_fixture* f) { grpc_end2end_local_fullstack_fixture_data* ffd = static_cast(f->fixture_data); - grpc_core::Delete(ffd); + delete ffd; } diff --git a/test/core/end2end/fixtures/proxy.cc b/test/core/end2end/fixtures/proxy.cc index 3351eab2f3c..ff6ee12ca77 100644 --- a/test/core/end2end/fixtures/proxy.cc +++ b/test/core/end2end/fixtures/proxy.cc @@ -89,7 +89,7 @@ grpc_end2end_proxy* grpc_end2end_proxy_create(const grpc_end2end_proxy_def* def, int proxy_port = grpc_pick_unused_port_or_die(); int server_port = grpc_pick_unused_port_or_die(); - grpc_end2end_proxy* proxy = grpc_core::New(); + grpc_end2end_proxy* proxy = new grpc_end2end_proxy(); grpc_core::JoinHostPort(&proxy->proxy_port, "localhost", proxy_port); grpc_core::JoinHostPort(&proxy->server_port, "localhost", server_port); @@ -134,7 +134,7 @@ void grpc_end2end_proxy_destroy(grpc_end2end_proxy* proxy) { grpc_channel_destroy(proxy->client); grpc_completion_queue_destroy(proxy->cq); grpc_call_details_destroy(&proxy->new_call_details); - grpc_core::Delete(proxy); + delete proxy; } static void unrefpc(proxy_call* pc, const char* /*reason*/) { diff --git a/test/core/end2end/fuzzers/api_fuzzer.cc b/test/core/end2end/fuzzers/api_fuzzer.cc index 7cc2360b920..b1eb33a042b 100644 --- a/test/core/end2end/fuzzers/api_fuzzer.cc +++ b/test/core/end2end/fuzzers/api_fuzzer.cc @@ -355,14 +355,14 @@ static void finish_resolve(void* arg, grpc_error* error) { } gpr_free(r->addr); - grpc_core::Delete(r); + delete r; } void my_resolve_address(const char* addr, const char* /*default_port*/, grpc_pollset_set* /*interested_parties*/, grpc_closure* on_done, grpc_resolved_addresses** addrs) { - addr_req* r = grpc_core::New(); + addr_req* r = new addr_req(); r->addr = gpr_strdup(addr); r->on_done = on_done; r->addrs = addrs; diff --git a/test/core/end2end/h2_ssl_cert_test.cc b/test/core/end2end/h2_ssl_cert_test.cc index 9bdacc3f137..61f685045e7 100644 --- a/test/core/end2end/h2_ssl_cert_test.cc +++ b/test/core/end2end/h2_ssl_cert_test.cc @@ -48,8 +48,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( grpc_channel_args* /*client_args*/, grpc_channel_args* /*server_args*/) { grpc_end2end_test_fixture f; int port = grpc_pick_unused_port_or_die(); - fullstack_secure_fixture_data* ffd = - grpc_core::New(); + fullstack_secure_fixture_data* ffd = new fullstack_secure_fixture_data(); memset(&f, 0, sizeof(f)); grpc_core::JoinHostPort(&ffd->localaddr, "localhost", port); @@ -98,7 +97,7 @@ static void chttp2_init_server_secure_fullstack( void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture* f) { fullstack_secure_fixture_data* ffd = static_cast(f->fixture_data); - grpc_core::Delete(ffd); + delete ffd; } static int fail_server_auth_check(grpc_channel_args* server_args) { diff --git a/test/core/end2end/inproc_callback_test.cc b/test/core/end2end/inproc_callback_test.cc index 15376c59d51..8d51421d4c0 100644 --- a/test/core/end2end/inproc_callback_test.cc +++ b/test/core/end2end/inproc_callback_test.cc @@ -46,7 +46,7 @@ class CQDeletingCallback : public grpc_experimental_completion_queue_functor { static void Run(grpc_experimental_completion_queue_functor* cb, int ok) { auto* callback = static_cast(cb); callback->func_(static_cast(ok)); - grpc_core::Delete(callback); + delete callback; } private: @@ -55,7 +55,7 @@ class CQDeletingCallback : public grpc_experimental_completion_queue_functor { template grpc_experimental_completion_queue_functor* NewDeletingCallback(F f) { - return grpc_core::New>(f); + return new CQDeletingCallback(f); } class ShutdownCallback : public grpc_experimental_completion_queue_functor { @@ -212,7 +212,7 @@ static grpc_end2end_test_fixture inproc_create_fixture( memset(&f, 0, sizeof(f)); f.fixture_data = ffd; - g_shutdown_callback = grpc_core::New(); + g_shutdown_callback = new ShutdownCallback(); f.cq = grpc_completion_queue_create_for_callback(g_shutdown_callback, nullptr); f.shutdown_cq = grpc_completion_queue_create_for_pluck(nullptr); @@ -263,7 +263,7 @@ static void drain_cq(grpc_completion_queue* /*cq*/) { // Wait for the shutdown callback to arrive, or fail the test GPR_ASSERT(g_shutdown_callback->Wait(five_seconds_from_now())); gpr_log(GPR_DEBUG, "CQ shutdown wait complete"); - grpc_core::Delete(g_shutdown_callback); + delete g_shutdown_callback; } static void shutdown_server(grpc_end2end_test_fixture* f) { diff --git a/test/core/gprpp/BUILD b/test/core/gprpp/BUILD index 773406e85cd..b22a651f8ce 100644 --- a/test/core/gprpp/BUILD +++ b/test/core/gprpp/BUILD @@ -82,20 +82,6 @@ grpc_cc_test( ], ) -grpc_cc_test( - name = "memory_test", - srcs = ["memory_test.cc"], - external_deps = [ - "gtest", - ], - language = "C++", - uses_polling = False, - deps = [ - "//:gpr_base", - "//test/core/util:grpc_test_util", - ], -) - grpc_cc_test( name = "inlined_vector_test", srcs = ["inlined_vector_test.cc"], diff --git a/test/core/gprpp/inlined_vector_test.cc b/test/core/gprpp/inlined_vector_test.cc index 03e116aa2a4..fdbc9ed971a 100644 --- a/test/core/gprpp/inlined_vector_test.cc +++ b/test/core/gprpp/inlined_vector_test.cc @@ -72,7 +72,7 @@ TEST(InlinedVectorTest, PushBackWithMove) { TEST(InlinedVectorTest, EmplaceBack) { InlinedVector, 1> v; - v.emplace_back(New(3)); + v.emplace_back(new int(3)); EXPECT_EQ(1UL, v.size()); EXPECT_EQ(3, *v[0]); } diff --git a/test/core/gprpp/memory_test.cc b/test/core/gprpp/memory_test.cc deleted file mode 100644 index b148d7dfccb..00000000000 --- a/test/core/gprpp/memory_test.cc +++ /dev/null @@ -1,95 +0,0 @@ -/* - * - * Copyright 2017 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include "src/core/lib/gprpp/memory.h" -#include -#include "test/core/util/test_config.h" - -namespace grpc_core { -namespace testing { - -struct Foo { - Foo(int p, int q) : a(p), b(q) {} - int a; - int b; -}; - -struct Base1 { - int a; - virtual ~Base1() {} -}; - -struct Base2 { - int b; - virtual ~Base2() {} -}; - -struct Compound : public Base1, Base2 { - int c; - virtual ~Compound() {} -}; - -TEST(MemoryTest, NewDeleteTest) { Delete(New()); } - -TEST(MemoryTest, NewDeleteWithArgTest) { - int* i = New(42); - EXPECT_EQ(42, *i); - Delete(i); -} - -TEST(MemoryTest, NewDeleteWithArgsTest) { - Foo* p = New(1, 2); - EXPECT_EQ(1, p->a); - EXPECT_EQ(2, p->b); - Delete(p); -} - -TEST(MemoryTest, MakeUniqueTest) { MakeUnique(); } - -TEST(MemoryTest, MakeUniqueWithArgTest) { - auto i = MakeUnique(42); - EXPECT_EQ(42, *i); -} - -TEST(MemoryTest, UniquePtrWithCustomDeleter) { - int n = 0; - class IncrementingDeleter { - public: - void operator()(int* p) { ++*p; } - }; - { - UniquePtr p(&n); - EXPECT_EQ(0, n); - } - EXPECT_EQ(1, n); -} - -TEST(MemoryTest, MultipleInheritence) { - Base2* p = New(); - EXPECT_NE(p, dynamic_cast(p)); - Delete(p); -} - -} // namespace testing -} // namespace grpc_core - -int main(int argc, char** argv) { - grpc::testing::TestEnvironment env(argc, argv); - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/test/core/gprpp/mpscq_test.cc b/test/core/gprpp/mpscq_test.cc index a3b6bb59e4b..d19a362f279 100644 --- a/test/core/gprpp/mpscq_test.cc +++ b/test/core/gprpp/mpscq_test.cc @@ -38,7 +38,7 @@ typedef struct test_node { } test_node; static test_node* new_node(size_t i, size_t* ctr) { - test_node* n = grpc_core::New(); + test_node* n = new test_node(); n->i = i; n->ctr = ctr; return n; diff --git a/test/core/gprpp/orphanable_test.cc b/test/core/gprpp/orphanable_test.cc index fe13df0d0d0..341b753548a 100644 --- a/test/core/gprpp/orphanable_test.cc +++ b/test/core/gprpp/orphanable_test.cc @@ -31,7 +31,7 @@ class Foo : public Orphanable { public: Foo() : Foo(0) {} explicit Foo(int value) : value_(value) {} - void Orphan() override { Delete(this); } + void Orphan() override { delete this; } int value() const { return value_; } private: @@ -39,12 +39,12 @@ class Foo : public Orphanable { }; TEST(Orphanable, Basic) { - Foo* foo = New(); + Foo* foo = new Foo(); foo->Orphan(); } TEST(OrphanablePtr, Basic) { - OrphanablePtr foo(New()); + OrphanablePtr foo(new Foo()); EXPECT_EQ(0, foo->value()); } diff --git a/test/core/gprpp/ref_counted_ptr_test.cc b/test/core/gprpp/ref_counted_ptr_test.cc index 38bd4b61364..e392c2058e4 100644 --- a/test/core/gprpp/ref_counted_ptr_test.cc +++ b/test/core/gprpp/ref_counted_ptr_test.cc @@ -48,31 +48,31 @@ TEST(RefCountedPtr, ExplicitConstructorEmpty) { RefCountedPtr foo(nullptr); } -TEST(RefCountedPtr, ExplicitConstructor) { RefCountedPtr foo(New()); } +TEST(RefCountedPtr, ExplicitConstructor) { RefCountedPtr foo(new Foo()); } TEST(RefCountedPtr, MoveConstructor) { - RefCountedPtr foo(New()); + RefCountedPtr foo(new Foo()); RefCountedPtr foo2(std::move(foo)); EXPECT_EQ(nullptr, foo.get()); EXPECT_NE(nullptr, foo2.get()); } TEST(RefCountedPtr, MoveAssignment) { - RefCountedPtr foo(New()); + RefCountedPtr foo(new Foo()); RefCountedPtr foo2 = std::move(foo); EXPECT_EQ(nullptr, foo.get()); EXPECT_NE(nullptr, foo2.get()); } TEST(RefCountedPtr, CopyConstructor) { - RefCountedPtr foo(New()); + RefCountedPtr foo(new Foo()); const RefCountedPtr& foo2(foo); EXPECT_NE(nullptr, foo.get()); EXPECT_EQ(foo.get(), foo2.get()); } TEST(RefCountedPtr, CopyAssignment) { - RefCountedPtr foo(New()); + RefCountedPtr foo(new Foo()); const RefCountedPtr& foo2 = foo; EXPECT_NE(nullptr, foo.get()); EXPECT_EQ(foo.get(), foo2.get()); @@ -87,12 +87,12 @@ TEST(RefCountedPtr, CopyAssignmentWhenEmpty) { } TEST(RefCountedPtr, CopyAssignmentToSelf) { - RefCountedPtr foo(New()); + RefCountedPtr foo(new Foo()); foo = *&foo; // The "*&" avoids warnings from LLVM -Wself-assign. } TEST(RefCountedPtr, EnclosedScope) { - RefCountedPtr foo(New()); + RefCountedPtr foo(new Foo()); { RefCountedPtr foo2(std::move(foo)); EXPECT_EQ(nullptr, foo.get()); @@ -104,21 +104,21 @@ TEST(RefCountedPtr, EnclosedScope) { TEST(RefCountedPtr, ResetFromNullToNonNull) { RefCountedPtr foo; EXPECT_EQ(nullptr, foo.get()); - foo.reset(New()); + foo.reset(new Foo()); EXPECT_NE(nullptr, foo.get()); } TEST(RefCountedPtr, ResetFromNonNullToNonNull) { - RefCountedPtr foo(New()); + RefCountedPtr foo(new Foo()); EXPECT_NE(nullptr, foo.get()); Foo* original = foo.get(); - foo.reset(New()); + foo.reset(new Foo()); EXPECT_NE(nullptr, foo.get()); EXPECT_NE(original, foo.get()); } TEST(RefCountedPtr, ResetFromNonNullToNull) { - RefCountedPtr foo(New()); + RefCountedPtr foo(new Foo()); EXPECT_NE(nullptr, foo.get()); foo.reset(); EXPECT_EQ(nullptr, foo.get()); @@ -132,14 +132,14 @@ TEST(RefCountedPtr, ResetFromNullToNull) { } TEST(RefCountedPtr, DerefernceOperators) { - RefCountedPtr foo(New()); + RefCountedPtr foo(new Foo()); foo->value(); Foo& foo_ref = *foo; foo_ref.value(); } TEST(RefCountedPtr, EqualityOperators) { - RefCountedPtr foo(New()); + RefCountedPtr foo(new Foo()); RefCountedPtr bar = foo; RefCountedPtr empty; // Test equality between RefCountedPtrs. @@ -152,8 +152,8 @@ TEST(RefCountedPtr, EqualityOperators) { } TEST(RefCountedPtr, Swap) { - Foo* foo = New(); - Foo* bar = New(); + Foo* foo = new Foo(); + Foo* bar = new Foo(); RefCountedPtr ptr1(foo); RefCountedPtr ptr2(bar); ptr1.swap(ptr2); @@ -183,7 +183,7 @@ class FooWithTracing : public RefCounted { }; TEST(RefCountedPtr, RefCountedWithTracing) { - RefCountedPtr foo(New()); + RefCountedPtr foo(new FooWithTracing()); RefCountedPtr foo2 = foo->Ref(DEBUG_LOCATION, "foo"); foo2.release(); foo->Unref(DEBUG_LOCATION, "foo"); @@ -200,7 +200,7 @@ class Subclass : public BaseClass { }; TEST(RefCountedPtr, ConstructFromSubclass) { - RefCountedPtr p(New()); + RefCountedPtr p(new Subclass()); } TEST(RefCountedPtr, CopyAssignFromSubclass) { @@ -222,12 +222,12 @@ TEST(RefCountedPtr, MoveAssignFromSubclass) { TEST(RefCountedPtr, ResetFromSubclass) { RefCountedPtr b; EXPECT_EQ(nullptr, b.get()); - b.reset(New()); + b.reset(new Subclass()); EXPECT_NE(nullptr, b.get()); } TEST(RefCountedPtr, EqualityWithSubclass) { - Subclass* s = New(); + Subclass* s = new Subclass(); RefCountedPtr b(s); EXPECT_EQ(b, s); } diff --git a/test/core/gprpp/ref_counted_test.cc b/test/core/gprpp/ref_counted_test.cc index 1955be33115..3205d7c6725 100644 --- a/test/core/gprpp/ref_counted_test.cc +++ b/test/core/gprpp/ref_counted_test.cc @@ -36,12 +36,12 @@ class Foo : public RefCounted { }; TEST(RefCounted, Basic) { - Foo* foo = New(); + Foo* foo = new Foo(); foo->Unref(); } TEST(RefCounted, ExtraRef) { - Foo* foo = New(); + Foo* foo = new Foo(); RefCountedPtr foop = foo->Ref(); foop.release(); foo->Unref(); @@ -58,12 +58,12 @@ class FooNonPolymorphic }; TEST(RefCountedNonPolymorphic, Basic) { - FooNonPolymorphic* foo = New(); + FooNonPolymorphic* foo = new FooNonPolymorphic(); foo->Unref(); } TEST(RefCountedNonPolymorphic, ExtraRef) { - FooNonPolymorphic* foo = New(); + FooNonPolymorphic* foo = new FooNonPolymorphic(); RefCountedPtr foop = foo->Ref(); foop.release(); foo->Unref(); @@ -80,7 +80,7 @@ class FooWithTracing : public RefCounted { }; TEST(RefCountedWithTracing, Basic) { - FooWithTracing* foo = New(); + FooWithTracing* foo = new FooWithTracing(); RefCountedPtr foop = foo->Ref(DEBUG_LOCATION, "extra_ref"); foop.release(); foo->Unref(DEBUG_LOCATION, "extra_ref"); @@ -98,7 +98,7 @@ class FooNonPolymorphicWithTracing }; TEST(RefCountedNonPolymorphicWithTracing, Basic) { - FooNonPolymorphicWithTracing* foo = New(); + FooNonPolymorphicWithTracing* foo = new FooNonPolymorphicWithTracing(); RefCountedPtr foop = foo->Ref(DEBUG_LOCATION, "extra_ref"); foop.release(); diff --git a/test/core/iomgr/mpmcqueue_test.cc b/test/core/iomgr/mpmcqueue_test.cc index 9ebc1cc7363..9c3d2210dee 100644 --- a/test/core/iomgr/mpmcqueue_test.cc +++ b/test/core/iomgr/mpmcqueue_test.cc @@ -49,7 +49,7 @@ class ProducerThread { ~ProducerThread() { for (int i = 0; i < num_items_; ++i) { GPR_ASSERT(items_[i]->done); - grpc_core::Delete(items_[i]); + delete items_[i]; } gpr_free(items_); } @@ -62,7 +62,7 @@ class ProducerThread { items_ = static_cast(gpr_zalloc(num_items_ * sizeof(WorkItem*))); for (int i = 0; i < num_items_; ++i) { - items_[i] = grpc_core::New(start_index_ + i); + items_[i] = new WorkItem(start_index_ + i); queue_->Put(items_[i]); } } @@ -109,13 +109,13 @@ static void test_FIFO(void) { gpr_log(GPR_INFO, "test_FIFO"); grpc_core::InfLenFIFOQueue large_queue; for (int i = 0; i < TEST_NUM_ITEMS; ++i) { - large_queue.Put(static_cast(grpc_core::New(i))); + large_queue.Put(static_cast(new WorkItem(i))); } GPR_ASSERT(large_queue.count() == TEST_NUM_ITEMS); for (int i = 0; i < TEST_NUM_ITEMS; ++i) { WorkItem* item = static_cast(large_queue.Get()); GPR_ASSERT(i == item->index); - grpc_core::Delete(item); + delete item; } } @@ -125,7 +125,7 @@ static void test_space_efficiency(void) { gpr_log(GPR_INFO, "test_space_efficiency"); grpc_core::InfLenFIFOQueue queue; for (int i = 0; i < queue.init_num_nodes(); ++i) { - queue.Put(static_cast(grpc_core::New(i))); + queue.Put(static_cast(new WorkItem(i))); } // Queue should not have been expanded at this time. GPR_ASSERT(queue.num_nodes() == queue.init_num_nodes()); @@ -136,34 +136,34 @@ static void test_space_efficiency(void) { GPR_ASSERT(queue.num_nodes() == queue.init_num_nodes()); for (int i = 0; i < queue.init_num_nodes(); ++i) { WorkItem* item = static_cast(queue.Get()); - grpc_core::Delete(item); + delete item; } // Queue never shrinks even it is empty. GPR_ASSERT(queue.num_nodes() == queue.init_num_nodes()); GPR_ASSERT(queue.count() == 0); // queue empty now for (int i = 0; i < queue.init_num_nodes() * 2; ++i) { - queue.Put(static_cast(grpc_core::New(i))); + queue.Put(static_cast(new WorkItem(i))); } GPR_ASSERT(queue.count() == queue.init_num_nodes() * 2); // Queue should have been expanded once. GPR_ASSERT(queue.num_nodes() == queue.init_num_nodes() * 2); for (int i = 0; i < queue.init_num_nodes(); ++i) { WorkItem* item = static_cast(queue.Get()); - grpc_core::Delete(item); + delete item; } GPR_ASSERT(queue.count() == queue.init_num_nodes()); // Queue will never shrink, should keep same number of node as before. GPR_ASSERT(queue.num_nodes() == queue.init_num_nodes() * 2); for (int i = 0; i < queue.init_num_nodes() + 1; ++i) { - queue.Put(static_cast(grpc_core::New(i))); + queue.Put(static_cast(new WorkItem(i))); } GPR_ASSERT(queue.count() == queue.init_num_nodes() * 2 + 1); // Queue should have been expanded twice. GPR_ASSERT(queue.num_nodes() == queue.init_num_nodes() * 4); for (int i = 0; i < queue.init_num_nodes() * 2 + 1; ++i) { WorkItem* item = static_cast(queue.Get()); - grpc_core::Delete(item); + delete item; } GPR_ASSERT(queue.count() == 0); GPR_ASSERT(queue.num_nodes() == queue.init_num_nodes() * 4); @@ -182,14 +182,14 @@ static void test_many_thread(void) { gpr_log(GPR_DEBUG, "Fork ProducerThreads..."); for (int i = 0; i < num_producer_threads; ++i) { - producer_threads[i] = grpc_core::New( - &queue, i * TEST_NUM_ITEMS, TEST_NUM_ITEMS); + producer_threads[i] = + new ProducerThread(&queue, i * TEST_NUM_ITEMS, TEST_NUM_ITEMS); producer_threads[i]->Start(); } gpr_log(GPR_DEBUG, "ProducerThreads Started."); gpr_log(GPR_DEBUG, "Fork ConsumerThreads..."); for (int i = 0; i < num_consumer_threads; ++i) { - consumer_threads[i] = grpc_core::New(&queue); + consumer_threads[i] = new ConsumerThread(&queue); consumer_threads[i]->Start(); } gpr_log(GPR_DEBUG, "ConsumerThreads Started."); @@ -209,11 +209,11 @@ static void test_many_thread(void) { gpr_log(GPR_DEBUG, "Checking WorkItems and Cleaning Up..."); for (int i = 0; i < num_producer_threads; ++i) { // Destructor of ProducerThread will do the check of WorkItems - grpc_core::Delete(producer_threads[i]); + delete producer_threads[i]; } gpr_free(producer_threads); for (int i = 0; i < num_consumer_threads; ++i) { - grpc_core::Delete(consumer_threads[i]); + delete consumer_threads[i]; } gpr_free(consumer_threads); gpr_log(GPR_DEBUG, "Done."); diff --git a/test/core/iomgr/threadpool_test.cc b/test/core/iomgr/threadpool_test.cc index 4edabc1d3b6..952cec34fea 100644 --- a/test/core/iomgr/threadpool_test.cc +++ b/test/core/iomgr/threadpool_test.cc @@ -27,10 +27,9 @@ static const int kThreadLargeIter = 10000; static void test_size_zero(void) { gpr_log(GPR_INFO, "test_size_zero"); - grpc_core::ThreadPool* pool_size_zero = - grpc_core::New(0); + grpc_core::ThreadPool* pool_size_zero = new grpc_core::ThreadPool(0); GPR_ASSERT(pool_size_zero->pool_capacity() == 1); - Delete(pool_size_zero); + delete pool_size_zero; } static void test_constructor_option(void) { @@ -38,10 +37,10 @@ static void test_constructor_option(void) { // Tests options grpc_core::Thread::Options options; options.set_stack_size(192 * 1024); // Random non-default value - grpc_core::ThreadPool* pool = grpc_core::New( - 0, "test_constructor_option", options); + grpc_core::ThreadPool* pool = + new grpc_core::ThreadPool(0, "test_constructor_option", options); GPR_ASSERT(pool->thread_options().stack_size() == options.stack_size()); - Delete(pool); + delete pool; } // Simple functor for testing. It will count how many times being called. @@ -69,15 +68,15 @@ class SimpleFunctorForAdd : public grpc_experimental_completion_queue_functor { static void test_add(void) { gpr_log(GPR_INFO, "test_add"); grpc_core::ThreadPool* pool = - grpc_core::New(kSmallThreadPoolSize, "test_add"); + new grpc_core::ThreadPool(kSmallThreadPoolSize, "test_add"); - SimpleFunctorForAdd* functor = grpc_core::New(); + SimpleFunctorForAdd* functor = new SimpleFunctorForAdd(); for (int i = 0; i < kThreadSmallIter; ++i) { pool->Add(functor); } - grpc_core::Delete(pool); + delete pool; GPR_ASSERT(functor->count() == kThreadSmallIter); - grpc_core::Delete(functor); + delete functor; gpr_log(GPR_DEBUG, "Done."); } @@ -111,29 +110,29 @@ class WorkThread { static void test_multi_add(void) { gpr_log(GPR_INFO, "test_multi_add"); const int num_work_thds = 10; - grpc_core::ThreadPool* pool = grpc_core::New( - kLargeThreadPoolSize, "test_multi_add"); - SimpleFunctorForAdd* functor = grpc_core::New(); + grpc_core::ThreadPool* pool = + new grpc_core::ThreadPool(kLargeThreadPoolSize, "test_multi_add"); + SimpleFunctorForAdd* functor = new SimpleFunctorForAdd(); WorkThread** work_thds = static_cast( gpr_zalloc(sizeof(WorkThread*) * num_work_thds)); gpr_log(GPR_DEBUG, "Fork threads for adding..."); for (int i = 0; i < num_work_thds; ++i) { - work_thds[i] = grpc_core::New(pool, functor, kThreadLargeIter); + work_thds[i] = new WorkThread(pool, functor, kThreadLargeIter); work_thds[i]->Start(); } // Wait for all threads finish gpr_log(GPR_DEBUG, "Waiting for all work threads finish..."); for (int i = 0; i < num_work_thds; ++i) { work_thds[i]->Join(); - grpc_core::Delete(work_thds[i]); + delete work_thds[i]; } gpr_free(work_thds); gpr_log(GPR_DEBUG, "Done."); gpr_log(GPR_DEBUG, "Waiting for all closures finish..."); // Destructor of thread pool will wait for all closures to finish - grpc_core::Delete(pool); + delete pool; GPR_ASSERT(functor->count() == kThreadLargeIter * num_work_thds); - grpc_core::Delete(functor); + delete functor; gpr_log(GPR_DEBUG, "Done."); } @@ -161,19 +160,18 @@ static void test_one_thread_FIFO(void) { gpr_log(GPR_INFO, "test_one_thread_FIFO"); int counter = 0; grpc_core::ThreadPool* pool = - grpc_core::New(1, "test_one_thread_FIFO"); + new grpc_core::ThreadPool(1, "test_one_thread_FIFO"); SimpleFunctorCheckForAdd** check_functors = static_cast( gpr_zalloc(sizeof(SimpleFunctorCheckForAdd*) * kThreadSmallIter)); for (int i = 0; i < kThreadSmallIter; ++i) { - check_functors[i] = - grpc_core::New(i + 1, &counter); + check_functors[i] = new SimpleFunctorCheckForAdd(i + 1, &counter); pool->Add(check_functors[i]); } // Destructor of pool will wait until all closures finished. - grpc_core::Delete(pool); + delete pool; for (int i = 0; i < kThreadSmallIter; ++i) { - grpc_core::Delete(check_functors[i]); + delete check_functors[i]; } gpr_free(check_functors); gpr_log(GPR_DEBUG, "Done."); diff --git a/test/core/iomgr/udp_server_test.cc b/test/core/iomgr/udp_server_test.cc index 84a93154b4f..27532035318 100644 --- a/test/core/iomgr/udp_server_test.cc +++ b/test/core/iomgr/udp_server_test.cc @@ -113,12 +113,12 @@ class TestGrpcUdpHandlerFactory : public GrpcUdpHandlerFactory { public: GrpcUdpHandler* CreateUdpHandler(grpc_fd* emfd, void* user_data) override { gpr_log(GPR_INFO, "create udp handler for fd %d", grpc_fd_wrapped_fd(emfd)); - return grpc_core::New(emfd, user_data); + return new TestGrpcUdpHandler(emfd, user_data); } void DestroyUdpHandler(GrpcUdpHandler* handler) override { gpr_log(GPR_INFO, "Destroy handler"); - grpc_core::Delete(reinterpret_cast(handler)); + delete reinterpret_cast(handler); } }; diff --git a/test/core/security/credentials_test.cc b/test/core/security/credentials_test.cc index 884f93fb255..93c66c73370 100644 --- a/test/core/security/credentials_test.cc +++ b/test/core/security/credentials_test.cc @@ -442,8 +442,7 @@ class check_channel_oauth2 final : public grpc_channel_credentials { static void test_channel_oauth2_composite_creds(void) { grpc_core::ExecCtx exec_ctx; grpc_channel_args* new_args; - grpc_channel_credentials* channel_creds = - grpc_core::New(); + grpc_channel_credentials* channel_creds = new check_channel_oauth2(); grpc_call_credentials* oauth2_creds = grpc_access_token_credentials_create("blah", nullptr); grpc_channel_credentials* channel_oauth2_creds = @@ -523,7 +522,7 @@ static void test_channel_oauth2_google_iam_composite_creds(void) { grpc_core::ExecCtx exec_ctx; grpc_channel_args* new_args; grpc_channel_credentials* channel_creds = - grpc_core::New(); + new check_channel_oauth2_google_iam(); grpc_call_credentials* oauth2_creds = grpc_access_token_credentials_create("blah", nullptr); grpc_channel_credentials* channel_oauth2_creds = diff --git a/test/core/surface/completion_queue_test.cc b/test/core/surface/completion_queue_test.cc index d53b6756772..f775cd28534 100644 --- a/test/core/surface/completion_queue_test.cc +++ b/test/core/surface/completion_queue_test.cc @@ -429,7 +429,7 @@ static void test_callback(void) { gpr_cv_signal(&cv); } gpr_mu_unlock(&mu); - grpc_core::Delete(callback); + delete callback; }; private: @@ -438,7 +438,7 @@ static void test_callback(void) { }; for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) { - tags[i] = static_cast(grpc_core::New(&counter, i)); + tags[i] = static_cast(new TagCallback(&counter, i)); sumtags += i; } diff --git a/test/core/transport/connectivity_state_test.cc b/test/core/transport/connectivity_state_test.cc index 5a82bb5979a..8e5b2b4fe2e 100644 --- a/test/core/transport/connectivity_state_test.cc +++ b/test/core/transport/connectivity_state_test.cc @@ -97,7 +97,7 @@ TEST(StateTracker, SubscribeThenUnsubscribe) { bool destroyed = false; ConnectivityStateTracker tracker("xxx", GRPC_CHANNEL_IDLE); ConnectivityStateWatcherInterface* watcher = - New(&count, &state, &destroyed); + new Watcher(&count, &state, &destroyed); tracker.AddWatcher(GRPC_CHANNEL_IDLE, OrphanablePtr(watcher)); // No initial notification, since we started the watch from the @@ -117,7 +117,7 @@ TEST(StateTracker, OrphanUponShutdown) { bool destroyed = false; ConnectivityStateTracker tracker("xxx", GRPC_CHANNEL_IDLE); ConnectivityStateWatcherInterface* watcher = - New(&count, &state, &destroyed); + new Watcher(&count, &state, &destroyed); tracker.AddWatcher(GRPC_CHANNEL_IDLE, OrphanablePtr(watcher)); // No initial notification, since we started the watch from the @@ -137,7 +137,7 @@ TEST(StateTracker, AddWhenAlreadyShutdown) { bool destroyed = false; ConnectivityStateTracker tracker("xxx", GRPC_CHANNEL_SHUTDOWN); ConnectivityStateWatcherInterface* watcher = - New(&count, &state, &destroyed); + new Watcher(&count, &state, &destroyed); tracker.AddWatcher(GRPC_CHANNEL_IDLE, OrphanablePtr(watcher)); EXPECT_TRUE(destroyed); diff --git a/test/core/util/test_lb_policies.cc b/test/core/util/test_lb_policies.cc index d70bf42e1ee..fd1547f4c6a 100644 --- a/test/core/util/test_lb_policies.cc +++ b/test/core/util/test_lb_policies.cc @@ -93,7 +93,7 @@ class InterceptRecvTrailingMetadataLoadBalancingPolicy InterceptRecvTrailingMetadataLoadBalancingPolicy( Args args, InterceptRecvTrailingMetadataCallback cb, void* user_data) : ForwardingLoadBalancingPolicy( - UniquePtr(New( + UniquePtr(new Helper( RefCountedPtr( this), cb, user_data)), @@ -154,7 +154,7 @@ class InterceptRecvTrailingMetadataLoadBalancingPolicy UniquePtr picker) override { parent_->channel_control_helper()->UpdateState( state, UniquePtr( - New(std::move(picker), cb_, user_data_))); + new Picker(std::move(picker), cb_, user_data_))); } void RequestReresolution() override { @@ -241,7 +241,7 @@ void RegisterInterceptRecvTrailingMetadataLoadBalancingPolicy( InterceptRecvTrailingMetadataCallback cb, void* user_data) { LoadBalancingPolicyRegistry::Builder::RegisterLoadBalancingPolicyFactory( UniquePtr( - New(cb, user_data))); + new InterceptTrailingFactory(cb, user_data))); } } // namespace grpc_core diff --git a/test/cpp/client/credentials_test.cc b/test/cpp/client/credentials_test.cc index 160a7a36566..af4c8532ef9 100644 --- a/test/cpp/client/credentials_test.cc +++ b/test/cpp/client/credentials_test.cc @@ -332,8 +332,7 @@ TEST_F(CredentialsTest, TlsCredentialReloadConfigSchedule) { new TestTlsCredentialReload()); std::shared_ptr config( new TlsCredentialReloadConfig(test_credential_reload)); - grpc_tls_credential_reload_arg* c_arg = - grpc_core::New(); + grpc_tls_credential_reload_arg* c_arg = new grpc_tls_credential_reload_arg(); c_arg->context = nullptr; TlsCredentialReloadArg* arg = new TlsCredentialReloadArg(c_arg); std::shared_ptr key_materials_config( @@ -368,7 +367,7 @@ TEST_F(CredentialsTest, TlsCredentialReloadConfigSchedule) { // Cleanup. gpr_free(const_cast(error_details_before_schedule)); - grpc_core::Delete(c_arg->key_materials_config); + delete c_arg->key_materials_config; if (c_arg->destroy_context != nullptr) { c_arg->destroy_context(c_arg->context); } @@ -424,7 +423,7 @@ TEST_F(CredentialsTest, TlsCredentialReloadConfigCppToC) { // Cleanup. c_arg.destroy_context(c_arg.context); - ::grpc_core::Delete(config.c_config()); + ::delete config.c_config(); } typedef class ::grpc_impl::experimental::TlsServerAuthorizationCheckArg @@ -474,7 +473,7 @@ TEST_F(CredentialsTest, TlsServerAuthorizationCheckConfigSchedule) { test_server_authorization_check(new TestTlsServerAuthorizationCheck()); TlsServerAuthorizationCheckConfig config(test_server_authorization_check); grpc_tls_server_authorization_check_arg* c_arg = - grpc_core::New(); + new grpc_tls_server_authorization_check_arg(); c_arg->context = nullptr; TlsServerAuthorizationCheckArg* arg = new TlsServerAuthorizationCheckArg(c_arg); @@ -641,7 +640,7 @@ TEST_F(CredentialsTest, TlsCredentialsOptionsCppToC) { "sync_error_details"); // Cleanup. - ::grpc_core::Delete(c_credential_reload_arg.key_materials_config); + ::delete c_credential_reload_arg.key_materials_config; c_credential_reload_arg.destroy_context(c_credential_reload_arg.context); c_server_authorization_check_arg.destroy_context( c_server_authorization_check_arg.context); @@ -649,8 +648,8 @@ TEST_F(CredentialsTest, TlsCredentialsOptionsCppToC) { gpr_free(const_cast(c_server_authorization_check_arg.target_name)); gpr_free(const_cast(c_server_authorization_check_arg.peer_cert)); gpr_free(const_cast(c_server_authorization_check_arg.error_details)); - ::grpc_core::Delete(c_credential_reload_config); - ::grpc_core::Delete(c_server_authorization_check_config); + ::delete c_credential_reload_config; + ::delete c_server_authorization_check_config; gpr_free(c_options); } diff --git a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc index 8deceb45162..9bafcf1dcd3 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc @@ -440,7 +440,7 @@ static void BM_HpackParserInitDestroy(benchmark::State& state) { grpc_chttp2_hpack_parser_init(&p); // Note that grpc_chttp2_hpack_parser_destroy frees the table dynamic // elements so we need to recreate it here. In actual operation, - // grpc_core::New allocates the table once + // new grpc_chttp2_hpack_parser_destroy allocates the table once // and for all. new (&p.table) grpc_chttp2_hptbl(); grpc_chttp2_hpack_parser_destroy(&p); diff --git a/test/cpp/microbenchmarks/bm_threadpool.cc b/test/cpp/microbenchmarks/bm_threadpool.cc index 792b57cf3cb..9f813fa972c 100644 --- a/test/cpp/microbenchmarks/bm_threadpool.cc +++ b/test/cpp/microbenchmarks/bm_threadpool.cc @@ -151,7 +151,7 @@ static void BM_ThreadPoolExternalAdd(benchmark::State& state) { // Setup for each run of test. if (state.thread_index == 0) { const int num_threads = state.range(1); - external_add_pool = grpc_core::New(num_threads); + external_add_pool = new grpc_core::ThreadPool(num_threads); } const int num_iterations = state.range(0) / state.threads; while (state.KeepRunningBatch(num_iterations)) { @@ -165,7 +165,7 @@ static void BM_ThreadPoolExternalAdd(benchmark::State& state) { // Teardown at the end of each test run. if (state.thread_index == 0) { state.SetItemsProcessed(state.range(0)); - grpc_core::Delete(external_add_pool); + delete external_add_pool; } } BENCHMARK(BM_ThreadPoolExternalAdd) diff --git a/test/cpp/naming/cancel_ares_query_test.cc b/test/cpp/naming/cancel_ares_query_test.cc index 86408fb49fc..e53c57ed261 100644 --- a/test/cpp/naming/cancel_ares_query_test.cc +++ b/test/cpp/naming/cancel_ares_query_test.cc @@ -165,7 +165,7 @@ void TestCancelActiveDNSQuery(ArgsStruct* args) { grpc_core::ResolverRegistry::CreateResolver( client_target, nullptr, args->pollset_set, args->lock, grpc_core::UniquePtr( - grpc_core::New(args))); + new AssertFailureResultHandler(args))); gpr_free(client_target); resolver->StartLocked(); // Without resetting and causing resolver shutdown, the diff --git a/test/cpp/naming/resolver_component_test.cc b/test/cpp/naming/resolver_component_test.cc index ac170e4a99a..d14caa996da 100644 --- a/test/cpp/naming/resolver_component_test.cc +++ b/test/cpp/naming/resolver_component_test.cc @@ -423,7 +423,7 @@ class ResultHandler : public grpc_core::Resolver::ResultHandler { static grpc_core::UniquePtr Create( ArgsStruct* args) { return grpc_core::UniquePtr( - grpc_core::New(args)); + new ResultHandler(args)); } explicit ResultHandler(ArgsStruct* args) : args_(args) {} @@ -456,7 +456,7 @@ class CheckingResultHandler : public ResultHandler { static grpc_core::UniquePtr Create( ArgsStruct* args) { return grpc_core::UniquePtr( - grpc_core::New(args)); + new CheckingResultHandler(args)); } explicit CheckingResultHandler(ArgsStruct* args) : ResultHandler(args) {} @@ -559,7 +559,7 @@ void RunResolvesRelevantRecordsTest( if (FLAGS_inject_broken_nameserver_list == "True") { g_fake_non_responsive_dns_server_port = grpc_pick_unused_port_or_die(); fake_non_responsive_dns_server.reset( - grpc_core::New( + new grpc::testing::FakeNonResponsiveDNSServer( g_fake_non_responsive_dns_server_port)); grpc_ares_test_only_inject_config = InjectBrokenNameServerList; GPR_ASSERT( diff --git a/tools/codegen/core/gen_static_metadata.py b/tools/codegen/core/gen_static_metadata.py index b83d13f9f3d..e8ce31bd07f 100755 --- a/tools/codegen/core/gen_static_metadata.py +++ b/tools/codegen/core/gen_static_metadata.py @@ -526,7 +526,7 @@ uint64_t StaticMetadataInitCanary() { void grpc_init_static_metadata_ctx(void) { grpc_core::g_static_metadata_slice_ctx - = grpc_core::New(); + = new grpc_core::StaticMetadataCtx(); grpc_core::g_static_metadata_slice_table = grpc_core::g_static_metadata_slice_ctx->slices; grpc_core::g_static_metadata_slice_refcounts @@ -538,8 +538,7 @@ void grpc_init_static_metadata_ctx(void) { } void grpc_destroy_static_metadata_ctx(void) { - grpc_core::Delete( - grpc_core::g_static_metadata_slice_ctx); + delete grpc_core::g_static_metadata_slice_ctx; grpc_core::g_static_metadata_slice_ctx = nullptr; grpc_core::g_static_metadata_slice_table = nullptr; grpc_core::g_static_metadata_slice_refcounts = nullptr; diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 263a382bbc8..e6bd18bcfdb 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -5019,30 +5019,6 @@ ], "uses_polling": true }, - { - "args": [], - "benchmark": false, - "ci_platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [], - "flaky": false, - "gtest": true, - "language": "c++", - "name": "memory_test", - "platforms": [ - "linux", - "mac", - "posix", - "windows" - ], - "uses_polling": false - }, { "args": [], "benchmark": false,