destroy#

Release the native context attached to a Digest::SHA object.

The Perl destructor. Invoked automatically when the last reference to a Digest::SHA object goes out of scope — you do not normally call it yourself. It frees the heap-allocated hashing context behind the blessed reference.

Synopsis#

{
    my $sha = Digest::SHA->new(256);
    # ... use $sha ...
}   # DESTROY runs here when $sha leaves scope

What you get back#

Nothing. DESTROY returns to Perl with no value.

Examples#

my $sha = Digest::SHA->new(256);
undef $sha;    # triggers DESTROY
## Double-free safety: explicit DESTROY followed by scope exit is harmless.

my $sha = Digest::SHA->new(256);
$sha->DESTROY;

## automatic DESTROY on scope exit is a no-op after the explicit call

Edge cases#

  • Calling DESTROY on an object that is not a blessed Digest::SHA reference is silently ignored.

  • After DESTROY, the object’s internal pointer is zeroed, so repeated calls are safe.

Differences from upstream#

Fully compatible with upstream Digest::SHA 6.04.

See also#

  • new — counterpart: allocates the context that DESTROY releases.

  • clone — each clone also owns a context and is destroyed independently.