Free memory allocated with [`cuda_malloc`](fn.cuda_malloc.html). # Errors If freeing memory fails, returns the CUDA error value. If the given pointer is null, returns InvalidValue. # Safety The given pointer must have been allocated with `cuda_malloc`, or null. The caller is responsible for ensuring that no other pointers to the deallocated buffer exist. # Examples ``` # let _context = cust:
(ptr: DevicePointer<T>)
| 172 | /// } |
| 173 | /// ``` |
| 174 | pub unsafe fn cuda_free<T: DeviceCopy>(ptr: DevicePointer<T>) -> CudaResult<()> { |
| 175 | if ptr.is_null() { |
| 176 | return Err(CudaError::InvalidMemoryAllocation); |
| 177 | } |
| 178 | |
| 179 | cuda::cuMemFree_v2(ptr.as_raw()).to_result()?; |
| 180 | Ok(()) |
| 181 | } |
| 182 | |
| 183 | /// Free memory allocated with [`cuda_malloc_unified`](fn.cuda_malloc_unified.html). |
| 184 | /// |