diff options
| author | Tom Pratt <tom.pratt@outlook.com> | 2026-05-18 10:25:39 +0200 |
|---|---|---|
| committer | Tom Pratt <tompratt@squareup.com> | 2026-05-19 12:03:01 +0200 |
| commit | f63b81dd3963b3e25be707c4e1df7fdb24f220ed (patch) | |
| tree | 06872b2463c49fccda0eab12bbcb71e7461d1d60 /Source | |
| parent | 22863b37032e023631257400f9958f1988fdf514 (diff) | |
Use unique_ptr when creating netplay client / server
Diffstat (limited to 'Source')
| -rw-r--r-- | Source/Android/jni/NetPlay/Netplay.cpp | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/Source/Android/jni/NetPlay/Netplay.cpp b/Source/Android/jni/NetPlay/Netplay.cpp index 06212e8c1d..e98dc28742 100644 --- a/Source/Android/jni/NetPlay/Netplay.cpp +++ b/Source/Android/jni/NetPlay/Netplay.cpp @@ -119,17 +119,14 @@ Java_org_dolphinemu_dolphinemu_features_netplay_NetplaySession_nativeJoin(JNIEnv host_port = Config::Get(Config::NETPLAY_CONNECT_PORT); } - auto* client = new NetPlay::NetPlayClient( + auto client = std::make_unique<NetPlay::NetPlayClient>( host_ip, host_port, ui, nickname, NetPlay::NetTraversalConfig{is_traversal, traversal_host, traversal_port}); if (!client->IsConnected()) - { - delete client; return 0; - } - return reinterpret_cast<jlong>(client); + return reinterpret_cast<jlong>(client.release()); } JNIEXPORT jlong JNICALL @@ -147,15 +144,12 @@ Java_org_dolphinemu_dolphinemu_features_netplay_NetplaySession_nativeHost(JNIEnv const u16 host_port = is_traversal ? Config::Get(Config::NETPLAY_LISTEN_PORT) : Config::Get(Config::NETPLAY_HOST_PORT); - auto* server = new NetPlay::NetPlayServer( + auto server = std::make_unique<NetPlay::NetPlayServer>( host_port, use_upnp, ui, NetPlay::NetTraversalConfig{is_traversal, traversal_host, traversal_port, traversal_port_alt}); if (!server->is_connected) - { - delete server; return 0; - } const std::string network_mode = Config::Get(Config::NETPLAY_NETWORK_MODE); const bool host_input_authority = @@ -163,7 +157,7 @@ Java_org_dolphinemu_dolphinemu_features_netplay_NetplaySession_nativeHost(JNIEnv server->SetHostInputAuthority(host_input_authority); server->AdjustPadBufferSize(Config::Get(Config::NETPLAY_BUFFER_SIZE)); - return reinterpret_cast<jlong>(server); + return reinterpret_cast<jlong>(server.release()); } JNIEXPORT void JNICALL |
