@@ -29,9 +29,10 @@ pub trait INSData : INSObject {
2929
3030 fn with_bytes ( bytes : & [ u8 ] ) -> Id < Self > {
3131 let cls = Self :: class ( ) ;
32+ let bytes_ptr = bytes. as_ptr ( ) as * const c_void ;
3233 unsafe {
3334 let obj: * mut Self = msg_send ! [ cls, alloc] ;
34- let obj: * mut Self = msg_send ! [ obj, initWithBytes: bytes . as_ptr ( )
35+ let obj: * mut Self = msg_send ! [ obj, initWithBytes: bytes_ptr
3536 length: bytes. len( ) ] ;
3637 Id :: from_retained_ptr ( obj)
3738 }
@@ -47,10 +48,11 @@ pub trait INSData : INSObject {
4748 let dealloc: & Block < ( * mut c_void , usize ) , ( ) > = & dealloc;
4849
4950 let mut bytes = bytes;
51+ let bytes_ptr = bytes. as_mut_ptr ( ) as * mut c_void ;
5052 let cls = Self :: class ( ) ;
5153 unsafe {
5254 let obj: * mut Self = msg_send ! [ cls, alloc] ;
53- let obj: * mut Self = msg_send ! [ obj, initWithBytesNoCopy: bytes . as_mut_ptr ( )
55+ let obj: * mut Self = msg_send ! [ obj, initWithBytesNoCopy: bytes_ptr
5456 length: bytes. len( )
5557 deallocator: dealloc] ;
5658 mem:: forget ( bytes) ;
@@ -92,17 +94,19 @@ pub trait INSMutableData : INSData {
9294 }
9395
9496 fn append ( & mut self , bytes : & [ u8 ] ) {
97+ let bytes_ptr = bytes. as_ptr ( ) as * const c_void ;
9598 unsafe {
96- let _: ( ) = msg_send ! [ self , appendBytes: bytes . as_ptr ( )
99+ let _: ( ) = msg_send ! [ self , appendBytes: bytes_ptr
97100 length: bytes. len( ) ] ;
98101 }
99102 }
100103
101104 fn replace_range ( & mut self , range : Range < usize > , bytes : & [ u8 ] ) {
102105 let range = NSRange :: from_range ( range) ;
106+ let bytes_ptr = bytes. as_ptr ( ) as * const c_void ;
103107 unsafe {
104108 let _: ( ) = msg_send ! [ self , replaceBytesInRange: range
105- withBytes: bytes . as_ptr ( )
109+ withBytes: bytes_ptr
106110 length: bytes. len( ) ] ;
107111 }
108112 }
0 commit comments