Ada.Unchecked_Deallocation
A generic procedure that frees the sole owned designated object and nulls its access value.
Read the family guide for representation, selection and resource rules. The complete declaration page retains exact signatures/contracts; the source specification is the implementation baseline.
Availability and ownership
An instance frees the object an access value owns and makes the access value null. The freed object must own nothing itself, or what it owns would leak (B6005).
A client proof uses these contracts without proving the body again (see library assurance). Global => null excludes package-global effects, not changes made through an in out argument.
Import and instantiate
For an already declared owned access type Name designating Object, instantiate the procedure:
with Ada.Unchecked_Deallocation;
procedure Free is new Ada.Unchecked_Deallocation (Object, Name);The corresponding Varc procedure-instance declaration is:
import Ada.Unchecked_Deallocation;
fn Free = new Ada.Unchecked_Deallocation<Object, Name>;
Object and Name must already denote the matching designated/access types; this declaration is neither a package instance nor an untyped address-deallocation API.
Vibe does not instantiate library generics; see library use across syntaxes. In Varc, keep each name's declared spelling and write & on arguments the call changes.
Contract and lifecycle reading
A Pre condition is the caller's obligation; a Post is what a normal return guarantees. What a postcondition does not state, a client cannot assume. Ghost functions are for contracts and ghost code. The family guide describes copying, lifetime, order and cost.
API 001
Unchecked_Deallocation generic procedure (declaration) — Instantiate a typed owner-deallocation procedure; frees the designated object if present and nulls its sole access owner. Nested owned resources and aliases must satisfy the language leak/ownership rules.
On normal return the declared contract establishes:
X = null