Function swift_runtime_sys::root::swift::swift_release

source ·
pub unsafe extern "C" fn swift_release(object: *mut HeapObject)
Expand description

Atomically decrements the retain count of an object. If the retain count reaches zero, the object is destroyed as follows:

size_t allocSize = object->metadata->destroy(object); if (allocSize) swift_deallocObject(object, allocSize);

\param object - may be null, in which case this is a no-op

POSSIBILITIES: We may end up wanting a bunch of different variants:

  • the general version which correctly handles null values, swift objects, and ObjC objects
    • a variant that assumes that its operand is a swift object
      • a variant that can safely use non-atomic operations
      • maybe a variant that can assume a non-null object It’s unlikely that a custom CC would be beneficial here.