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

Method drop

crates/cust/src/memory/unified.rs:229–244  ·  view source on GitHub ↗

Destroy a `UnifiedBox`, returning an error. Deallocating unified memory can return errors from previous asynchronous work. This function destroys the given box and returns the error and the un-destroyed box on failure. # Example ``` # let _context = cust::quick_init().unwrap(); use cust::memory::*; let x = UnifiedBox::new(5).unwrap(); match UnifiedBox::drop(x) { Ok(()) => println!("Successfully

(mut uni_box: UnifiedBox<T>)

Source from the content-addressed store, hash-verified

227 /// }
228 /// ```
229 pub fn drop(mut uni_box: UnifiedBox<T>) -> DropResult<UnifiedBox<T>> {
230 if uni_box.ptr.is_null() {
231 return Ok(());
232 }
233
234 let ptr = mem::replace(&mut uni_box.ptr, UnifiedPointer::null());
235 unsafe {
236 match cuda_free_unified(ptr) {
237 Ok(()) => {
238 mem::forget(uni_box);
239 Ok(())
240 }
241 Err(e) => Err((e, UnifiedBox { ptr })),
242 }
243 }
244 }
245}
246impl<T: DeviceCopy> Drop for UnifiedBox<T> {
247 fn drop(&mut self) {

Callers

nothing calls this directly

Calls 3

cuda_free_unifiedFunction · 0.85
is_nullMethod · 0.80
from_raw_partsFunction · 0.70

Tested by

no test coverage detected