File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44
55use std:: {
66 borrow:: Cow ,
7- ffi:: { c_char, c_void , CStr } ,
7+ ffi:: { c_char, CStr } ,
88 panic:: AssertUnwindSafe ,
99 ptr:: NonNull ,
1010} ;
@@ -268,20 +268,14 @@ extern "C" fn start_task(
268268 . map_err ( |_e| crate :: Error :: CustomProtocolTaskInvalid ) ?;
269269
270270 let data = if content_len < NO_COPY_DATA_THRESHOLD {
271- let data = NSData :: alloc ( ) ;
272271 // Keep small responses on the original copy path; no-copy deallocation costs more.
273- NSData :: initWithBytes_length ( data , content. as_ptr ( ) as * mut c_void , content . len ( ) )
272+ NSData :: with_bytes ( content)
274273 } else {
275274 match sent_response. into_body ( ) {
276275 Cow :: Owned ( content) => NSData :: from_vec ( content) ,
277276 Cow :: Borrowed ( content) => {
278- let data = NSData :: alloc ( ) ;
279277 // Copy borrowed responses because NSData cannot take ownership.
280- NSData :: initWithBytes_length (
281- data,
282- content. as_ptr ( ) as * mut c_void ,
283- content. len ( ) ,
284- )
278+ NSData :: with_bytes ( content)
285279 }
286280 }
287281 } ;
You can’t perform that action at this time.
0 commit comments