MCPcopy Create free account
hub / github.com/Rust-GPU/rust-cuda / cuda_free_locked

Function cuda_free_locked

crates/cust/src/memory/malloc.rs:282–289  ·  view source on GitHub ↗

Free page-locked memory allocated with [`cuda_malloc_host`](fn.cuda_malloc_host.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_locked`, or null. The caller is responsible for ensuring that no other pointers to the deallocated buffer exist. # Example

(ptr: *mut T)

Source from the content-addressed store, hash-verified

280/// }
281/// ```
282pub unsafe fn cuda_free_locked<T>(ptr: *mut T) -> CudaResult<()> {
283 if ptr.is_null() {
284 return Err(CudaError::InvalidMemoryAllocation);
285 }
286
287 cuda::cuMemFreeHost(ptr as *mut c_void).to_result()?;
288 Ok(())
289}
290
291#[cfg(test)]
292mod test {

Callers 3

test_cuda_malloc_lockedFunction · 0.85
dropMethod · 0.85
dropMethod · 0.85

Calls 2

is_nullMethod · 0.80
to_resultMethod · 0.45

Tested by 1

test_cuda_malloc_lockedFunction · 0.68