@@ -43,8 +43,8 @@ impl Blob {
4343 pub fn allocate ( description : & TensorDesc ) -> Result < Self > {
4444 let mut instance = std:: ptr:: null_mut ( ) ;
4545 try_unsafe ! ( ie_blob_make_memory(
46- & description. instance as * const _ ,
47- & mut instance as * mut * mut _
46+ std :: ptr :: addr_of! ( description. instance) ,
47+ std :: ptr :: addr_of_mut! ( instance)
4848 ) ) ?;
4949 Ok ( Self { instance } )
5050 }
@@ -54,16 +54,19 @@ impl Blob {
5454 let blob = self . instance as * const ie_blob_t ;
5555
5656 let mut layout = Layout :: ANY ;
57- try_unsafe ! ( ie_blob_get_layout( blob, & mut layout as * mut _ ) ) ?;
57+ try_unsafe ! ( ie_blob_get_layout( blob, std :: ptr :: addr_of_mut! ( layout) ) ) ?;
5858
5959 let mut dimensions = dimensions_t {
6060 ranks : 0 ,
6161 dims : [ 0 ; 8usize ] ,
6262 } ;
63- try_unsafe ! ( ie_blob_get_dims( blob, & mut dimensions as * mut _ ) ) ?;
63+ try_unsafe ! ( ie_blob_get_dims( blob, std :: ptr :: addr_of_mut! ( dimensions) ) ) ?;
6464
6565 let mut precision = Precision :: UNSPECIFIED ;
66- try_unsafe ! ( ie_blob_get_precision( blob, & mut precision as * mut _) ) ?;
66+ try_unsafe ! ( ie_blob_get_precision(
67+ blob,
68+ std:: ptr:: addr_of_mut!( precision)
69+ ) ) ?;
6770
6871 Ok ( TensorDesc :: new ( layout, & dimensions. dims , precision) )
6972 }
@@ -75,7 +78,7 @@ impl Blob {
7578 /// Panics if the returned OpenVINO size will not fit in `usize`.
7679 pub fn len ( & mut self ) -> Result < usize > {
7780 let mut size = 0 ;
78- try_unsafe ! ( ie_blob_size( self . instance, & mut size as * mut _ ) ) ?;
81+ try_unsafe ! ( ie_blob_size( self . instance, std :: ptr :: addr_of_mut! ( size) ) ) ?;
7982 Ok ( usize:: try_from ( size) . unwrap ( ) )
8083 }
8184
@@ -86,14 +89,20 @@ impl Blob {
8689 /// Panics if the returned OpenVINO size will not fit in `usize`.
8790 pub fn byte_len ( & mut self ) -> Result < usize > {
8891 let mut size = 0 ;
89- try_unsafe ! ( ie_blob_byte_size( self . instance, & mut size as * mut _) ) ?;
92+ try_unsafe ! ( ie_blob_byte_size(
93+ self . instance,
94+ std:: ptr:: addr_of_mut!( size)
95+ ) ) ?;
9096 Ok ( usize:: try_from ( size) . unwrap ( ) )
9197 }
9298
9399 /// Retrieve the [`Blob`]'s data as an immutable slice of bytes.
94100 pub fn buffer ( & mut self ) -> Result < & [ u8 ] > {
95101 let mut buffer = Blob :: empty_buffer ( ) ;
96- try_unsafe ! ( ie_blob_get_buffer( self . instance, & mut buffer as * mut _) ) ?;
102+ try_unsafe ! ( ie_blob_get_buffer(
103+ self . instance,
104+ std:: ptr:: addr_of_mut!( buffer)
105+ ) ) ?;
97106 let size = self . byte_len ( ) ?;
98107 let slice = unsafe {
99108 std:: slice:: from_raw_parts ( buffer. __bindgen_anon_1 . buffer as * const u8 , size)
@@ -104,7 +113,10 @@ impl Blob {
104113 /// Retrieve the [`Blob`]'s data as a mutable slice of bytes.
105114 pub fn buffer_mut ( & mut self ) -> Result < & mut [ u8 ] > {
106115 let mut buffer = Blob :: empty_buffer ( ) ;
107- try_unsafe ! ( ie_blob_get_buffer( self . instance, & mut buffer as * mut _) ) ?;
116+ try_unsafe ! ( ie_blob_get_buffer(
117+ self . instance,
118+ std:: ptr:: addr_of_mut!( buffer)
119+ ) ) ?;
108120 let size = self . byte_len ( ) ?;
109121 let slice = unsafe {
110122 std:: slice:: from_raw_parts_mut ( buffer. __bindgen_anon_1 . buffer . cast :: < u8 > ( ) , size)
@@ -122,7 +134,10 @@ impl Blob {
122134 /// `results.buffer_mut_as_type::<f32>()`.
123135 pub unsafe fn buffer_mut_as_type < T > ( & mut self ) -> Result < & mut [ T ] > {
124136 let mut buffer = Blob :: empty_buffer ( ) ;
125- InferenceError :: from ( ie_blob_get_buffer ( self . instance , & mut buffer as * mut _ ) ) ?;
137+ InferenceError :: from ( ie_blob_get_buffer (
138+ self . instance ,
139+ std:: ptr:: addr_of_mut!( buffer) ,
140+ ) ) ?;
126141 // This is very unsafe, but very convenient: by allowing users to specify T, they can
127142 // retrieve the buffer in whatever shape they prefer. But we must ensure that they cannot
128143 // read too many bytes, so we manually calculate the resulting slice `size`.
0 commit comments