Skip to content

Commit 53fd10e

Browse files
committed
librustls: inline rustls_client_connection_new bindings
1 parent 47e6b0f commit 53fd10e

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

librustls/src/client.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -768,22 +768,19 @@ impl rustls_client_config {
768768
}
769769
CStr::from_ptr(server_name)
770770
};
771-
let config = try_clone_arc!(config);
772-
let conn_out = try_mut_from_ptr_ptr!(conn_out);
773-
774771
let Ok(server_name) = server_name.to_str() else {
775772
return rustls_result::InvalidDnsNameError;
776773
};
777774
let Ok(server_name) = server_name.try_into() else {
778775
return rustls_result::InvalidDnsNameError;
779776
};
780-
let client = ClientConnection::new(config, server_name).unwrap();
781777

782-
// We've succeeded. Put the client on the heap, and transfer ownership
783-
// to the caller. After this point, we must return rustls_result::Ok so the
784-
// caller knows it is responsible for this memory.
785-
let c = Connection::from_client(client);
786-
set_boxed_mut_ptr(conn_out, c);
778+
set_boxed_mut_ptr(
779+
try_mut_from_ptr_ptr!(conn_out),
780+
Connection::from_client(
781+
ClientConnection::new(try_clone_arc!(config), server_name).unwrap(),
782+
),
783+
);
787784
rustls_result::Ok
788785
}
789786
}

0 commit comments

Comments
 (0)