@@ -112,10 +112,10 @@ pub fn info_string(verbose: bool) -> String {
112112/// # Return Values
113113/// A tuple of `String` indicating the name, platform, toolkit and compute.
114114pub fn device_info ( ) -> ( String , String , String , String ) {
115- let mut name = [ 0 as c_char ; 64 ] ;
116- let mut platform = [ 0 as c_char ; 10 ] ;
117- let mut toolkit = [ 0 as c_char ; 64 ] ;
118- let mut compute = [ 0 as c_char ; 10 ] ;
115+ let mut name: [ c_char ; 64 ] = [ 0 ; 64 ] ;
116+ let mut platform: [ c_char ; 10 ] = [ 0 ; 10 ] ;
117+ let mut toolkit: [ c_char ; 64 ] = [ 0 ; 64 ] ;
118+ let mut compute: [ c_char ; 10 ] = [ 0 ; 10 ] ;
119119 unsafe {
120120 let err_val = af_device_info (
121121 & mut name[ 0 ] ,
@@ -320,6 +320,12 @@ pub fn sync(device: i32) {
320320}
321321
322322/// Allocate non-pageable memory on HOST memory
323+ ///
324+ /// # Safety
325+ ///
326+ /// Non-pageable memory allocations should be done by users
327+ /// who understand the consequences of such allocations on other
328+ /// tasks running on the system.
323329pub unsafe fn alloc_pinned ( bytes : usize ) -> void_ptr {
324330 let mut out: void_ptr = std:: ptr:: null_mut ( ) ;
325331 let err_val = af_alloc_pinned ( & mut out as * mut void_ptr , bytes as dim_t ) ;
@@ -328,6 +334,12 @@ pub unsafe fn alloc_pinned(bytes: usize) -> void_ptr {
328334}
329335
330336/// Free the pointer returned by [alloc_pinned](./fn.alloc_pinned.html)
337+ ///
338+ /// # Safety
339+ ///
340+ /// This function is intended to be called on pointers that were earlier
341+ /// allocated using [alloc_pinned](./fn.alloc_pinned.html). Any other values
342+ /// passed as argument would result in undefined behavior.
331343pub unsafe fn free_pinned ( ptr : void_ptr ) {
332344 let err_val = af_free_pinned ( ptr) ;
333345 HANDLE_ERROR ( AfError :: from ( err_val) ) ;
0 commit comments