Replaced grpc_core New & Delete with C++ new & delete

pull/20962/head
Esun Kim 5 years ago
parent cc43fd64ab
commit 3a519a0b64
  1. 38
      CMakeLists.txt
  2. 48
      Makefile
  3. 12
      build.yaml
  4. 28
      src/core/ext/filters/client_channel/client_channel.cc
  5. 10
      src/core/ext/filters/client_channel/global_subchannel_pool.cc
  6. 2
      src/core/ext/filters/client_channel/health/health_check_client.cc
  7. 6
      src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc
  8. 2
      src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc
  9. 2
      src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc
  10. 2
      src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc
  11. 6
      src/core/ext/filters/client_channel/lb_policy/subchannel_list.h
  12. 6
      src/core/ext/filters/client_channel/lb_policy/xds/xds.cc
  13. 4
      src/core/ext/filters/client_channel/lb_policy_registry.cc
  14. 6
      src/core/ext/filters/client_channel/local_subchannel_pool.cc
  15. 6
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc
  16. 8
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc
  17. 2
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc
  18. 10
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc
  19. 4
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc
  20. 18
      src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc
  21. 4
      src/core/ext/filters/client_channel/resolver_registry.cc
  22. 2
      src/core/ext/filters/client_channel/resolving_lb_policy.cc
  23. 4
      src/core/ext/filters/client_channel/service_config.cc
  24. 13
      src/core/ext/filters/client_channel/service_config.h
  25. 12
      src/core/ext/filters/client_channel/subchannel.cc
  26. 10
      src/core/ext/filters/client_channel/xds/xds_client.cc
  27. 4
      src/core/ext/filters/deadline/deadline_filter.cc
  28. 3
      src/core/ext/filters/max_age/max_age_filter.cc
  29. 2
      src/core/ext/transport/chttp2/client/insecure/channel_create.cc
  30. 2
      src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc
  31. 4
      src/core/ext/transport/chttp2/transport/chttp2_transport.cc
  32. 4
      src/core/ext/transport/chttp2/transport/context_list.cc
  33. 2
      src/core/ext/transport/chttp2/transport/frame_data.cc
  34. 6
      src/core/ext/transport/chttp2/transport/internal.h
  35. 6
      src/core/ext/transport/cronet/transport/cronet_transport.cc
  36. 8
      src/core/lib/channel/channel_trace.cc
  37. 4
      src/core/lib/channel/channelz_registry.cc
  38. 8
      src/core/lib/gprpp/fork.cc
  39. 35
      src/core/lib/gprpp/memory.h
  40. 6
      src/core/lib/gprpp/orphanable.h
  41. 6
      src/core/lib/gprpp/ref_counted.h
  42. 2
      src/core/lib/gprpp/ref_counted_ptr.h
  43. 2
      src/core/lib/gprpp/thd.h
  44. 6
      src/core/lib/gprpp/thd_posix.cc
  45. 6
      src/core/lib/gprpp/thd_windows.cc
  46. 4
      src/core/lib/http/httpcli_security_connector.cc
  47. 6
      src/core/lib/iomgr/buffer_list.cc
  48. 4
      src/core/lib/iomgr/cfstream_handle.cc
  49. 4
      src/core/lib/iomgr/combiner.cc
  50. 12
      src/core/lib/iomgr/executor.cc
  51. 8
      src/core/lib/iomgr/executor/threadpool.cc
  52. 2
      src/core/lib/iomgr/resolve_address_custom.cc
  53. 4
      src/core/lib/iomgr/tcp_server_posix.cc
  54. 4
      src/core/lib/iomgr/udp_server.cc
  55. 5
      src/core/lib/security/credentials/alts/alts_credentials.cc
  56. 8
      src/core/lib/security/credentials/composite/composite_credentials.cc
  57. 10
      src/core/lib/security/credentials/credentials.cc
  58. 4
      src/core/lib/security/credentials/credentials.h
  59. 7
      src/core/lib/security/credentials/fake/fake_credentials.cc
  60. 4
      src/core/lib/security/credentials/local/local_credentials.cc
  61. 2
      src/core/lib/security/credentials/oauth2/oauth2_credentials.cc
  62. 2
      src/core/lib/security/credentials/plugin/plugin_credentials.cc
  63. 8
      src/core/lib/security/credentials/ssl/ssl_credentials.cc
  64. 10
      src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc
  65. 4
      src/core/lib/security/credentials/tls/spiffe_credentials.cc
  66. 9
      src/core/lib/security/security_connector/tls/spiffe_security_connector.cc
  67. 8
      src/core/lib/security/transport/secure_endpoint.cc
  68. 21
      src/core/lib/slice/slice.cc
  69. 3
      src/core/lib/surface/server.cc
  70. 4
      src/core/lib/transport/connectivity_state.cc
  71. 18
      src/core/lib/transport/metadata.cc
  72. 6
      src/core/lib/transport/metadata.h
  73. 6
      src/core/lib/transport/static_metadata.cc
  74. 4
      src/core/lib/transport/transport.cc
  75. 4
      src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc
  76. 6
      src/core/tsi/ssl/session_cache/ssl_session_cache.cc
  77. 2
      src/objective-c/tests/CronetTests/CoreCronetEnd2EndTests.mm
  78. 2
      test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc
  79. 7
      test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc
  80. 2
      test/core/client_channel/resolvers/fake_resolver_test.cc
  81. 4
      test/core/end2end/bad_server_response_test.cc
  82. 4
      test/core/end2end/fixtures/h2_census.cc
  83. 4
      test/core/end2end/fixtures/h2_compress.cc
  84. 5
      test/core/end2end/fixtures/h2_fakesec.cc
  85. 4
      test/core/end2end/fixtures/h2_full+pipe.cc
  86. 4
      test/core/end2end/fixtures/h2_full+trace.cc
  87. 4
      test/core/end2end/fixtures/h2_full+workarounds.cc
  88. 4
      test/core/end2end/fixtures/h2_full.cc
  89. 4
      test/core/end2end/fixtures/h2_http_proxy.cc
  90. 5
      test/core/end2end/fixtures/h2_oauth2.cc
  91. 5
      test/core/end2end/fixtures/h2_spiffe.cc
  92. 5
      test/core/end2end/fixtures/h2_ssl.cc
  93. 5
      test/core/end2end/fixtures/h2_ssl_cred_reload.cc
  94. 4
      test/core/end2end/fixtures/http_proxy_fixture.cc
  95. 4
      test/core/end2end/fixtures/local_util.cc
  96. 4
      test/core/end2end/fixtures/proxy.cc
  97. 4
      test/core/end2end/fuzzers/api_fuzzer.cc
  98. 5
      test/core/end2end/h2_ssl_cert_test.cc
  99. 8
      test/core/end2end/inproc_callback_test.cc
  100. 14
      test/core/gprpp/BUILD
  101. Some files were not shown because too many files have changed in this diff Show More

@ -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

@ -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 \

@ -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

@ -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<ExternalConnectivityWatcher>(
external_watchers_[on_complete] = new ExternalConnectivityWatcher(
this, pollent, state, on_complete, watcher_timer_init);
}
@ -901,9 +901,9 @@ class ChannelData::SubchannelWrapper : public SubchannelInterface {
UniquePtr<ConnectivityStateWatcherInterface> watcher) override {
auto& watcher_wrapper = watcher_map_[watcher.get()];
GPR_ASSERT(watcher_wrapper == nullptr);
watcher_wrapper = New<WatcherWrapper>(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<char>(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<Updater>(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<WatcherWrapper>(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<WatcherWrapper> 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<ClientChannelControlHelper>(this);
lb_args.args = channel_args_;
UniquePtr<char> target_uri(gpr_strdup(target_uri_.get()));
resolving_lb_policy_.reset(New<ResolvingLoadBalancingPolicy>(
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<AsyncConnectivityStateWatcherInterface> watcher) {
New<ConnectivityWatcherAdder>(this, initial_state, std::move(watcher));
new ConnectivityWatcherAdder(this, initial_state, std::move(watcher));
}
void ChannelData::RemoveConnectivityWatcher(
AsyncConnectivityStateWatcherInterface* watcher) {
New<ConnectivityWatcherRemover>(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<QueuedPickCanceller>(elem);
pick_canceller_ = new QueuedPickCanceller(elem);
}
void CallData::ApplyServiceConfigToCallLocked(grpc_call_element* elem) {

@ -35,7 +35,7 @@ GlobalSubchannelPool::~GlobalSubchannelPool() {
}
void GlobalSubchannelPool::Init() {
instance_ = New<RefCountedPtr<GlobalSubchannelPool>>(
instance_ = new RefCountedPtr<GlobalSubchannelPool>(
MakeRefCounted<GlobalSubchannelPool>());
}
@ -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> 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<SubchannelKey>(*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<SubchannelKey*>(p);
Delete(key);
delete key;
}
void* sck_avl_copy(void* p, void* /*unused*/) {
const SubchannelKey* key = static_cast<const SubchannelKey*>(p);
auto* new_key = New<SubchannelKey>(*key);
auto* new_key = new SubchannelKey(*key);
return static_cast<void*>(new_key);
}

@ -400,7 +400,7 @@ void HealthCheckClient::CallState::AfterCallStackDestruction(
void* arg, grpc_error* /*error*/) {
HealthCheckClient::CallState* self =
static_cast<HealthCheckClient::CallState*>(arg);
Delete(self);
delete self;
}
void HealthCheckClient::CallState::OnCancelComplete(void* arg,

@ -1724,7 +1724,7 @@ grpc_channel_args* GrpcLb::CreateChildPolicyArgsLocked(
OrphanablePtr<LoadBalancingPolicy> GrpcLb::CreateChildPolicyLocked(
const char* name, const grpc_channel_args* args) {
Helper* helper = New<Helper>(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<LoadBalancingPolicy::Config>(
New<ParsedGrpcLbConfig>(nullptr));
new ParsedGrpcLbConfig(nullptr));
}
InlinedVector<grpc_error*, 2> error_list;
RefCountedPtr<LoadBalancingPolicy::Config> child_policy;
@ -1905,7 +1905,7 @@ class GrpcLbFactory : public LoadBalancingPolicyFactory {
}
if (error_list.empty()) {
return RefCountedPtr<LoadBalancingPolicy::Config>(
New<ParsedGrpcLbConfig>(std::move(child_policy)));
new ParsedGrpcLbConfig(std::move(child_policy)));
} else {
*error = GRPC_ERROR_CREATE_FROM_VECTOR("GrpcLb Parser", &error_list);
return nullptr;

@ -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<DroppedCallCounts>());
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) {

@ -495,7 +495,7 @@ class PickFirstFactory : public LoadBalancingPolicyFactory {
GPR_DEBUG_ASSERT(strcmp(json->key, name()) == 0);
}
return RefCountedPtr<LoadBalancingPolicy::Config>(
New<ParsedPickFirstConfig>());
new ParsedPickFirstConfig());
}
};

@ -491,7 +491,7 @@ class RoundRobinFactory : public LoadBalancingPolicyFactory {
GPR_DEBUG_ASSERT(strcmp(json->key, name()) == 0);
}
return RefCountedPtr<LoadBalancingPolicy::Config>(
New<ParsedRoundRobinConfig>());
new ParsedRoundRobinConfig());
}
};

@ -206,10 +206,6 @@ class SubchannelList : public InternallyRefCounted<SubchannelListType> {
virtual ~SubchannelList();
private:
// So New() can call our private ctor.
template <typename T, typename... Args>
friend T* New(Args&&... args);
// For accessing Ref() and Unref().
friend class SubchannelData<SubchannelListType, SubchannelDataType>;
@ -317,7 +313,7 @@ void SubchannelData<SubchannelListType,
}
GPR_ASSERT(pending_watcher_ == nullptr);
pending_watcher_ =
New<Watcher>(this, subchannel_list()->Ref(DEBUG_LOCATION, "Watcher"));
new Watcher(this, subchannel_list()->Ref(DEBUG_LOCATION, "Watcher"));
subchannel_->WatchConnectivityState(
connectivity_state_,
UniquePtr<SubchannelInterface::ConnectivityStateWatcherInterface>(

@ -992,7 +992,7 @@ void XdsLb::UpdateFallbackPolicyLocked() {
OrphanablePtr<LoadBalancingPolicy> XdsLb::CreateFallbackPolicyLocked(
const char* name, const grpc_channel_args* args) {
FallbackHelper* helper =
New<FallbackHelper>(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<LocalityMap>(
auto new_locality_map = new LocalityMap(
xds_policy_->Ref(DEBUG_LOCATION, "XdsLb+LocalityMap"), priority);
priorities_.emplace_back(OrphanablePtr<LocalityMap>(new_locality_map));
new_locality_map->UpdateLocked(*priority_list_update().Find(priority));
@ -1500,7 +1500,7 @@ XdsLb::PriorityList::LocalityMap::Locality::CreateChildPolicyArgsLocked(
OrphanablePtr<LoadBalancingPolicy>
XdsLb::PriorityList::LocalityMap::Locality::CreateChildPolicyLocked(
const char* name, const grpc_channel_args* args) {
Helper* helper = New<Helper>(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;

@ -64,11 +64,11 @@ RegistryState* g_state = nullptr;
//
void LoadBalancingPolicyRegistry::Builder::InitRegistry() {
if (g_state == nullptr) g_state = New<RegistryState>();
if (g_state == nullptr) g_state = new RegistryState();
}
void LoadBalancingPolicyRegistry::Builder::ShutdownRegistry() {
Delete(g_state);
delete g_state;
g_state = nullptr;
}

@ -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<SubchannelKey>(*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<SubchannelKey*>(p);
Delete(key);
delete key;
}
void* sck_avl_copy(void* p, void* /*unused*/) {
const SubchannelKey* key = static_cast<const SubchannelKey*>(p);
auto new_key = New<SubchannelKey>(*key);
auto new_key = new SubchannelKey(*key);
return static_cast<void*>(new_key);
}

@ -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<grpc_ares_ev_driver>();
*ev_driver = new grpc_ares_ev_driver();
ares_options opts;
memset(&opts, 0, sizeof(opts));
opts.flags |= ARES_FLAG_STAYOPEN;

@ -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<uv_poll_t>();
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<GrpcPolledFdLibuv*>(handle->data);
AresUvPollCbArg* arg = New<AresUvPollCbArg>(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<GrpcPolledFdLibuv>(as, combiner);
return new GrpcPolledFdLibuv(as, combiner);
}
void ConfigureAresChannelLocked(ares_channel channel) override {}

@ -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<GrpcPolledFdPosix>(as, driver_pollset_set);
return new GrpcPolledFdPosix(as, driver_pollset_set);
}
void ConfigureAresChannelLocked(ares_channel /*channel*/) override {}

@ -752,7 +752,7 @@ class SockToPolledFdMap {
}
void AddNewSocket(SOCKET s, GrpcPolledFdWindows* polled_fd) {
SockToPolledFdEntry* new_node = New<SockToPolledFdEntry>(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<GrpcPolledFdWindows>(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<GrpcPolledFdWindowsWrapper>(polled_fd);
return new GrpcPolledFdWindowsWrapper(polled_fd);
}
void ConfigureAresChannelLocked(ares_channel channel) override {

@ -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<grpc_resolve_address_ares_request>();
new grpc_resolve_address_ares_request();
r->combiner = grpc_combiner_create();
r->addrs_out = addrs;
r->on_resolve_address_done = on_done;

@ -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>();
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>();
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>();
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>();
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>();
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>();
SetResponseClosureArg* closure_arg = new SetResponseClosureArg();
closure_arg->resolver = resolver_->Ref();
closure_arg->result = std::move(result_);
resolver_->combiner()->Run(

@ -103,11 +103,11 @@ static RegistryState* g_state = nullptr;
//
void ResolverRegistry::Builder::InitRegistry() {
if (g_state == nullptr) g_state = New<RegistryState>();
if (g_state == nullptr) g_state = new RegistryState();
}
void ResolverRegistry::Builder::ShutdownRegistry() {
Delete(g_state);
delete g_state;
g_state = nullptr;
}

@ -371,7 +371,7 @@ OrphanablePtr<LoadBalancingPolicy>
ResolvingLoadBalancingPolicy::CreateLbPolicyLocked(
const char* lb_policy_name, const grpc_channel_args& args,
TraceStringVector* trace_strings) {
ResolvingControlHelper* helper = New<ResolvingControlHelper>(Ref());
ResolvingControlHelper* helper = new ResolvingControlHelper(Ref());
LoadBalancingPolicy::Args lb_policy_args;
lb_policy_args.combiner = combiner();
lb_policy_args.channel_control_helper =

@ -318,11 +318,11 @@ size_t ServiceConfig::RegisterParser(UniquePtr<Parser> parser) {
void ServiceConfig::Init() {
GPR_ASSERT(g_registered_parsers == nullptr);
g_registered_parsers = New<ServiceConfigParserList>();
g_registered_parsers = new ServiceConfigParserList();
}
void ServiceConfig::Shutdown() {
Delete(g_registered_parsers);
delete g_registered_parsers;
g_registered_parsers = nullptr;
}

@ -128,6 +128,10 @@ class ServiceConfig : public RefCounted<ServiceConfig> {
static RefCountedPtr<ServiceConfig> Create(const char* json,
grpc_error** error);
// Takes ownership of \a json_tree.
ServiceConfig(UniquePtr<char> service_config_json,
UniquePtr<char> 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<ServiceConfig> {
static void Shutdown();
private:
// So New() can call our private ctor.
template <typename T, typename... Args>
friend T* New(Args&&... args);
// Takes ownership of \a json_tree.
ServiceConfig(UniquePtr<char> service_config_json,
UniquePtr<char> 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);

@ -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<SubchannelKey>(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<Subchannel>(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<Subchannel*>(arg);
Delete(self);
delete self;
}
} // namespace
@ -1050,7 +1050,7 @@ bool Subchannel::PublishTransportLocked() {
}
// Publish.
connected_subchannel_.reset(
New<ConnectedSubchannel>(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) {

@ -378,16 +378,16 @@ bool XdsClient::ChannelState::HasActiveAdsCall() const {
void XdsClient::ChannelState::MaybeStartAdsCall() {
if (ads_calld_ != nullptr) return;
ads_calld_.reset(New<RetryableCall<AdsCallState>>(
Ref(DEBUG_LOCATION, "ChannelState+ads")));
ads_calld_.reset(
new RetryableCall<AdsCallState>(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<RetryableCall<LrsCallState>>(
Ref(DEBUG_LOCATION, "ChannelState+lrs")));
lrs_calld_.reset(
new RetryableCall<LrsCallState>(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<StateWatcher>(Ref());
watcher_ = new StateWatcher(Ref());
grpc_client_channel_start_connectivity_watch(
client_channel_elem, GRPC_CHANNEL_IDLE,
OrphanablePtr<AsyncConnectivityStateWatcherInterface>(watcher_));

@ -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<start_timer_after_init_state>(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);

@ -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<grpc_core::ConnectivityWatcher>(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,

@ -79,7 +79,7 @@ grpc_core::Chttp2InsecureClientChannelFactory* g_factory;
gpr_once g_factory_once = GPR_ONCE_INIT;
void FactoryInit() {
g_factory = grpc_core::New<grpc_core::Chttp2InsecureClientChannelFactory>();
g_factory = new grpc_core::Chttp2InsecureClientChannelFactory();
}
} // namespace

@ -181,7 +181,7 @@ grpc_core::Chttp2SecureClientChannelFactory* g_factory;
gpr_once g_factory_once = GPR_ONCE_INIT;
void FactoryInit() {
g_factory = grpc_core::New<grpc_core::Chttp2SecureClientChannelFactory>();
g_factory = new grpc_core::Chttp2SecureClientChannelFactory();
}
} // namespace

@ -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<grpc_chttp2_transport>(channel_args, ep, is_client,
resource_user);
auto t =
new grpc_chttp2_transport(channel_args, ep, is_client, resource_user);
return &t->base;
}

@ -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>();
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;
}
}

@ -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<grpc_core::Chttp2IncomingByteStream>(
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) {

@ -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) {

@ -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<op_and_state>(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");

@ -81,7 +81,7 @@ ChannelTrace::~ChannelTrace() {
while (it != nullptr) {
TraceEvent* to_free = it;
it = it->next();
Delete<TraceEvent>(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<TraceEvent>(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<TraceEvent>(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<TraceEvent>(severity, data, std::move(referenced_entity)));
new TraceEvent(severity, data, std::move(referenced_entity)));
}
namespace {

@ -43,9 +43,9 @@ const int kPaginationLimit = 100;
} // anonymous namespace
void ChannelzRegistry::Init() { g_channelz_registry = New<ChannelzRegistry>(); }
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);

@ -172,15 +172,15 @@ void Fork::GlobalInit() {
MemoryOrder::RELAXED);
}
if (support_enabled_.Load(MemoryOrder::RELAXED)) {
exec_ctx_state_ = grpc_core::New<internal::ExecCtxState>();
thread_state_ = grpc_core::New<internal::ThreadState>();
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_;
}
}

@ -30,13 +30,6 @@
namespace grpc_core {
// Alternative to new, to ensure memory allocation being wrapped to gpr_malloc
template <typename T, typename... Args>
inline T* New(Args&&... args) {
void* p = gpr_malloc(sizeof(T));
return new (p) T(std::forward<Args>(args)...);
}
// Gets the base pointer of any class, in case of multiple inheritance.
// Used by Delete and friends.
template <typename T, bool isPolymorphic>
@ -49,36 +42,12 @@ struct BasePointerGetter<T, true> {
static void* get(T* p) { return dynamic_cast<void*>(p); }
};
// Alternative to delete, to ensure memory allocation being wrapped to gpr_free
template <typename T>
inline void Delete(T* p) {
if (p == nullptr) return;
void* basePtr = BasePointerGetter<T, std::is_polymorphic<T>::value>::get(p);
p->~T();
gpr_free(basePtr);
}
class DefaultDelete {
public:
template <typename T>
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<T, std::is_polymorphic<T>::value>::get(p);
p->~T();
gpr_free(basePtr);
}
};
template <typename T, typename Deleter = DefaultDelete>
using UniquePtr = std::unique_ptr<T, Deleter>;
using UniquePtr = std::unique_ptr<T>;
template <typename T, typename... Args>
inline UniquePtr<T> MakeUnique(Args&&... args) {
return UniquePtr<T>(New<T>(std::forward<Args>(args)...));
return UniquePtr<T>(new T(std::forward<Args>(args)...));
}
// an allocator that uses gpr_malloc/gpr_free

@ -69,7 +69,7 @@ using OrphanablePtr = std::unique_ptr<T, Deleter>;
template <typename T, typename... Args>
inline OrphanablePtr<T> MakeOrphanable(Args&&... args) {
return OrphanablePtr<T>(New<T>(std::forward<Args>(args)...));
return OrphanablePtr<T>(new T(std::forward<Args>(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<Child*>(this));
delete static_cast<Child*>(this);
}
}
void Unref(const DebugLocation& location, const char* reason) {
if (GPR_UNLIKELY(refs_.Unref(location, reason))) {
Delete(static_cast<Child*>(this));
delete static_cast<Child*>(this);
}
}

@ -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<MyClass>
@ -267,12 +267,12 @@ class RefCounted : public Impl {
// friend of this class.
void Unref() {
if (GPR_UNLIKELY(refs_.Unref())) {
Delete(static_cast<Child*>(this));
delete static_cast<Child*>(this);
}
}
void Unref(const DebugLocation& location, const char* reason) {
if (GPR_UNLIKELY(refs_.Unref(location, reason))) {
Delete(static_cast<Child*>(this));
delete static_cast<Child*>(this);
}
}

@ -179,7 +179,7 @@ class RefCountedPtr {
template <typename T, typename... Args>
inline RefCountedPtr<T> MakeRefCounted(Args&&... args) {
return RefCountedPtr<T>(New<T>(std::forward<Args>(args)...));
return RefCountedPtr<T>(new T(std::forward<Args>(args)...));
}
} // namespace grpc_core

@ -144,7 +144,7 @@ class Thread {
void Join() {
if (impl_ != nullptr) {
impl_->Join();
grpc_core::Delete(impl_);
delete impl_;
state_ = DONE;
impl_ = nullptr;
} else {

@ -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<ThreadInternalsPosix>(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;
}

@ -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<ThreadInternalsWindows>(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;
}

@ -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<on_done_closure>(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<on_done_closure>();
auto* c = new on_done_closure();
const char* pem_root_certs =
grpc_core::DefaultSslRootStore::GetPemRootCerts();
const tsi_ssl_root_certs_store* root_store =

@ -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<TracedBuffer>(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<TracedBuffer>(elem);
delete static_cast<TracedBuffer*>(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<TracedBuffer>(elem);
delete elem;
elem = next;
}
*head = nullptr;

@ -53,7 +53,7 @@ void CFStreamHandle::Release(void* info) {
CFStreamHandle* CFStreamHandle::CreateStreamHandle(
CFReadStreamRef read_stream, CFWriteStreamRef write_stream) {
return grpc_core::New<CFStreamHandle>(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<CFStreamHandle>(this);
delete this;
}
}

@ -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>();
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) {

@ -393,9 +393,9 @@ void Executor::InitAll() {
}
executors[static_cast<size_t>(ExecutorType::DEFAULT)] =
grpc_core::New<Executor>("default-executor");
new Executor("default-executor");
executors[static_cast<size_t>(ExecutorType::RESOLVER)] =
grpc_core::New<Executor>("resolver-executor");
new Executor("resolver-executor");
executors[static_cast<size_t>(ExecutorType::DEFAULT)]->Init();
executors[static_cast<size_t>(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<Executor>(
executors[static_cast<size_t>(ExecutorType::DEFAULT)]);
grpc_core::Delete<Executor>(
executors[static_cast<size_t>(ExecutorType::RESOLVER)]);
delete executors[static_cast<size_t>(ExecutorType::DEFAULT)];
delete executors[static_cast<size_t>(ExecutorType::RESOLVER)];
executors[static_cast<size_t>(ExecutorType::DEFAULT)] = nullptr;
executors[static_cast<size_t>(ExecutorType::RESOLVER)] = nullptr;

@ -54,11 +54,11 @@ void ThreadPool::SharedThreadPoolConstructor() {
// Create at least 1 worker thread.
if (num_threads_ <= 0) num_threads_ = 1;
queue_ = New<InfLenFIFOQueue>();
queue_ = new InfLenFIFOQueue();
threads_ = static_cast<ThreadPoolWorker**>(
gpr_zalloc(num_threads_ * sizeof(ThreadPoolWorker*)));
for (int i = 0; i < num_threads_; ++i) {
threads_[i] = New<ThreadPoolWorker>(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) {

@ -92,7 +92,7 @@ static grpc_error* try_split_host_port(const char* name,
grpc_core::UniquePtr<char>* 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);

@ -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<ExternalConnectionHandler>(s);
s->fd_handler = new ExternalConnectionHandler(s);
return s->fd_handler;
}

@ -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>();
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*/) {

@ -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<grpc_alts_credentials>(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<grpc_alts_server_credentials>(options,
handshaker_service_url);
return new grpc_alts_server_credentials(options, handshaker_service_url);
}
grpc_channel_credentials* grpc_alts_credentials_create(

@ -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<grpc_composite_call_credentials_metadata_context>(
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<grpc_composite_channel_credentials>(
channel_creds->Ref(), call_creds->Ref());
return new grpc_composite_channel_credentials(channel_creds->Ref(),
call_creds->Ref());
}

@ -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::UniquePtr<char>,
grpc_core::RefCountedPtr<grpc_channel_credentials>,
grpc_core::StringLess>>();
g_grpc_control_plane_creds =
new std::map<grpc_core::UniquePtr<char>,
grpc_core::RefCountedPtr<grpc_channel_credentials>,
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);
}

@ -314,12 +314,12 @@ struct grpc_credentials_metadata_request {
inline grpc_credentials_metadata_request*
grpc_credentials_metadata_request_create(
grpc_core::RefCountedPtr<grpc_call_credentials> creds) {
return grpc_core::New<grpc_credentials_metadata_request>(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 */

@ -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<grpc_fake_channel_credentials>();
return new grpc_fake_channel_credentials();
}
grpc_server_credentials*
grpc_fake_transport_security_server_credentials_create() {
return grpc_core::New<grpc_fake_server_credentials>();
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<grpc_md_only_test_credentials>(md_key, md_value,
is_async);
return new grpc_md_only_test_credentials(md_key, md_value, is_async);
}

@ -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<grpc_local_credentials>(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<grpc_local_server_credentials>(connect_type);
return new grpc_local_server_credentials(connect_type);
}

@ -643,7 +643,7 @@ grpc_error* ValidateStsCredentialsOptions(
};
*sts_url_out = nullptr;
InlinedVector<grpc_error*, 3> error_list;
UniquePtr<grpc_uri, GrpcUriDeleter> sts_url(
std::unique_ptr<grpc_uri, GrpcUriDeleter> sts_url(
options->token_exchange_service_uri != nullptr
? grpc_uri_parse(options->token_exchange_service_uri, false)
: nullptr);

@ -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<grpc_plugin_credentials>(plugin);
return new grpc_plugin_credentials(plugin);
}

@ -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<grpc_ssl_credentials>(
return new grpc_ssl_credentials(
pem_root_certs, pem_key_cert_pair,
reinterpret_cast<const grpc_ssl_verify_peer_options*>(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<grpc_ssl_credentials>(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<grpc_ssl_server_credentials>(*options);
retval = new grpc_ssl_server_credentials(*options);
done:
grpc_ssl_server_credentials_options_destroy(options);

@ -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<grpc_tls_credentials_options>();
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<grpc_tls_key_materials_config>();
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<grpc_tls_credential_reload_config>(
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<grpc_tls_server_authorization_check_config>(
return new grpc_tls_server_authorization_check_config(
config_user_data, schedule, cancel, destruct);
}

@ -115,7 +115,7 @@ grpc_channel_credentials* grpc_tls_spiffe_credentials_create(
if (!CredentialOptionSanityCheck(options, true /* is_client */)) {
return nullptr;
}
return grpc_core::New<SpiffeCredentials>(
return new SpiffeCredentials(
grpc_core::RefCountedPtr<grpc_tls_credentials_options>(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<SpiffeServerCredentials>(
return new SpiffeServerCredentials(
grpc_core::RefCountedPtr<grpc_tls_credentials_options>(options));
}

@ -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>();
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<grpc_tls_server_authorization_check_arg>();
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(

@ -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<secure_endpoint>(
&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;
}

@ -73,9 +73,7 @@ static_assert(std::is_trivially_destructible<decltype(kNoopRefcount)>::value,
with the user provided data pointer & destroy function */
class NewSliceRefcount {
public:
static void Destroy(void* arg) {
Delete(static_cast<NewSliceRefcount*>(arg));
}
static void Destroy(void* arg) { delete static_cast<NewSliceRefcount*>(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<grpc_core::NewSliceRefcount>(destroy, user_data)
->base_refcount();
(new grpc_core::NewSliceRefcount(destroy, user_data))->base_refcount();
slice.data.refcounted.bytes = static_cast<uint8_t*>(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<NewWithLenSliceRefcount*>(arg));
delete static_cast<NewWithLenSliceRefcount*>(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<MovedStringSliceRefCount*>(arg));
delete static_cast<MovedStringSliceRefCount*>(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<grpc_core::NewWithLenSliceRefcount>(destroy, p, len)
->base_refcount();
slice.refcount = (new grpc_core::NewWithLenSliceRefcount(destroy, p, len))
->base_refcount();
slice.data.refcounted.bytes = static_cast<uint8_t*>(p);
slice.data.refcounted.length = len;
return slice;
@ -223,9 +219,8 @@ grpc_slice grpc_slice_from_moved_buffer(grpc_core::UniquePtr<char> p,
slice.data.inlined.length = len;
memcpy(GRPC_SLICE_START_PTR(slice), ptr, len);
} else {
slice.refcount =
grpc_core::New<grpc_core::MovedStringSliceRefCount>(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;
}

@ -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<ConnectivityWatcher>(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");

@ -79,7 +79,7 @@ class AsyncConnectivityStateWatcherInterface::Notifier {
self->watcher_.get(), ConnectivityStateName(self->state_));
}
self->watcher_->OnConnectivityStateChange(self->state_);
Delete(self);
delete self;
}
RefCountedPtr<AsyncConnectivityStateWatcherInterface> watcher_;
@ -89,7 +89,7 @@ class AsyncConnectivityStateWatcherInterface::Notifier {
void AsyncConnectivityStateWatcherInterface::Notify(
grpc_connectivity_state state) {
New<Notifier>(Ref(), state, combiner_); // Deletes itself when done.
new Notifier(Ref(), state, combiner_); // Deletes itself when done.
}
//

@ -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<AllocatedMetadata>(
new AllocatedMetadata(
key, value,
static_cast<const AllocatedMetadata::NoRefKey*>(
nullptr)),
GRPC_MDELEM_STORAGE_ALLOCATED)
: GRPC_MAKE_MDELEM(
grpc_core::New<AllocatedMetadata>(key, value),
GRPC_MDELEM_STORAGE_ALLOCATED);
: GRPC_MAKE_MDELEM(new AllocatedMetadata(key, value),
GRPC_MDELEM_STORAGE_ALLOCATED);
}
}
return md_create_maybe_static<key_definitely_static, value_definitely_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<InternedMetadata>(
? new InternedMetadata(
key, value, hash, shard->elems[idx].next,
static_cast<const InternedMetadata::NoRefKey*>(nullptr))
: grpc_core::New<InternedMetadata>(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<AllocatedMetadata*> 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<AllocatedMetadata*>(ptr));
delete reinterpret_cast<AllocatedMetadata*>(ptr);
break;
}
}

@ -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<AllocatedMetadata>(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<AllocatedMetadata>(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<AllocatedMetadata>(key, value),
return GRPC_MAKE_MDELEM(new AllocatedMetadata(key, value),
GRPC_MDELEM_STORAGE_ALLOCATED);
}

@ -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::StaticMetadataCtx>();
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::StaticMetadataCtx>(
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;

@ -221,11 +221,11 @@ static void destroy_made_transport_op(void* arg, grpc_error* error) {
made_transport_op* op = static_cast<made_transport_op*>(arg);
grpc_core::ExecCtx::Run(DEBUG_LOCATION, op->inner_on_complete,
GRPC_ERROR_REF(error));
grpc_core::Delete<made_transport_op>(op);
delete op;
}
grpc_transport_op* grpc_make_transport_op(grpc_closure* on_complete) {
made_transport_op* op = grpc_core::New<made_transport_op>();
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;

@ -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<alts_tsi_handshaker_continue_handshaker_next_args>();
new alts_tsi_handshaker_continue_handshaker_next_args();
args->handshaker = handshaker;
args->received_bytes = nullptr;
args->received_bytes_size = received_bytes_size;

@ -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<Node>(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();
}
}

@ -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>();
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);

@ -167,7 +167,7 @@ int main(int argc, char** argv) {
{
grpc_core::ExecCtx exec_ctx;
ResultHandler* result_handler = grpc_core::New<ResultHandler>();
ResultHandler* result_handler = new ResultHandler();
grpc_core::OrphanablePtr<grpc_core::Resolver> resolver = create_resolver(
"dns:test", grpc_core::UniquePtr<grpc_core::Resolver::ResultHandler>(
result_handler));

@ -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<OnResolutionCallbackArg*>(arg);
res_cb_arg->result_handler = grpc_core::New<ResultHandler>();
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>();
OnResolutionCallbackArg* res_cb_arg = new OnResolutionCallbackArg();
res_cb_arg->uri_str = "dns:127.0.0.1";
g_combiner->Run(

@ -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>();
ResultHandler* result_handler = new ResultHandler();
grpc_core::RefCountedPtr<grpc_core::FakeResolverResponseGenerator>
response_generator =
grpc_core::MakeRefCounted<grpc_core::FakeResolverResponseGenerator>();

@ -264,8 +264,8 @@ static grpc_core::Thread* poll_server_until_read_done(
poll_args* pa = static_cast<poll_args*>(gpr_malloc(sizeof(*pa)));
pa->server = server;
pa->signal_when_done = signal_when_done;
auto* th = grpc_core::New<grpc_core::Thread>("grpc_poll_server",
actually_poll_server, pa);
auto* th =
new grpc_core::Thread("grpc_poll_server", actually_poll_server, pa);
th->Start();
return th;
}

@ -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>();
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<fullstack_fixture_data*>(f->fixture_data);
grpc_core::Delete(ffd);
delete ffd;
}
/* All test configurations */

@ -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<fullstack_compression_fixture_data>();
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<fullstack_compression_fixture_data*>(f->fixture_data);
grpc_core::Delete(ffd);
delete ffd;
}
/* All test configurations */

@ -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>();
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<fullstack_secure_fixture_data*>(f->fixture_data);
grpc_core::Delete(ffd);
delete ffd;
}
static void chttp2_init_client_fake_secure_fullstack(

@ -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>();
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<fullstack_fixture_data*>(f->fixture_data);
grpc_core::Delete(ffd);
delete ffd;
}
/* All test configurations */

@ -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>();
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<fullstack_fixture_data*>(f->fixture_data);
grpc_core::Delete(ffd);
delete ffd;
}
/* All test configurations */

@ -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>();
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<fullstack_fixture_data*>(f->fixture_data);
grpc_core::Delete(ffd);
delete ffd;
}
/* All test configurations */

@ -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>();
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<fullstack_fixture_data*>(f->fixture_data);
grpc_core::Delete(ffd);
delete ffd;
}
/* All test configurations */

@ -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>();
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<fullstack_fixture_data*>(f->fixture_data);
grpc_core::Delete(ffd);
delete ffd;
}
/* All test configurations */

@ -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>();
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<fullstack_secure_fixture_data*>(f->fixture_data);
grpc_core::Delete(ffd);
delete ffd;
}
static void chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack(

@ -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>();
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<fullstack_secure_fixture_data*>(f->fixture_data);
grpc_core::Delete(ffd);
delete ffd;
}
// Application-provided callback for server authorization check.

@ -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>();
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<fullstack_secure_fixture_data*>(f->fixture_data);
grpc_core::Delete(ffd);
delete ffd;
}
static void chttp2_init_client_simple_ssl_secure_fullstack(

@ -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>();
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<fullstack_secure_fixture_data*>(f->fixture_data);
grpc_core::Delete(ffd);
delete ffd;
}
static void chttp2_init_client_simple_ssl_secure_fullstack(

@ -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>();
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(

@ -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<grpc_end2end_local_fullstack_fixture_data>();
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<grpc_end2end_local_fullstack_fixture_data*>(f->fixture_data);
grpc_core::Delete(ffd);
delete ffd;
}

@ -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>();
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*/) {

@ -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>();
addr_req* r = new addr_req();
r->addr = gpr_strdup(addr);
r->on_done = on_done;
r->addrs = addrs;

@ -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>();
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<fullstack_secure_fixture_data*>(f->fixture_data);
grpc_core::Delete(ffd);
delete ffd;
}
static int fail_server_auth_check(grpc_channel_args* server_args) {

@ -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<CQDeletingCallback*>(cb);
callback->func_(static_cast<bool>(ok));
grpc_core::Delete(callback);
delete callback;
}
private:
@ -55,7 +55,7 @@ class CQDeletingCallback : public grpc_experimental_completion_queue_functor {
template <typename F>
grpc_experimental_completion_queue_functor* NewDeletingCallback(F f) {
return grpc_core::New<CQDeletingCallback<F>>(f);
return new CQDeletingCallback<F>(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<ShutdownCallback>();
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) {

@ -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"],

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save