destroy#
Release the native MD5 state buffer when a context object is reaped.
Synopsis#
## Called automatically — you do not invoke DESTROY yourself.
undef $ctx; # triggers DESTROY on the last reference
What you get back#
Nothing. DESTROY is Perl’s object finaliser hook; it runs when
the last reference to a Digest::MD5 object goes away, frees the
MD5_CTX buffer that was allocated alongside the object, and
returns no value.
You almost never call this directly. It is documented here so readers doing memory audits or writing subclasses know that the module owns a raw buffer behind the blessed reference and that the buffer is reclaimed on normal refcount-driven destruction.
Examples#
Destruction happens when the last reference drops, either at
scope exit or via explicit undef:
{
my $ctx = Digest::MD5->new;
$ctx->add("data");
} # DESTROY runs here
Explicit drop mid-scope:
my $ctx = Digest::MD5->new;
$ctx->add("data");
undef $ctx; # DESTROY runs now, context is freed
Edge cases#
Tolerant of malformed input: if the object does not carry the expected magic,
DESTROYreturns silently rather than croaking. This matches upstream and is important becauseDESTROYcan be called during global destruction in arbitrary order.Running on an already-destroyed context (possible during global destruction cycles) is a no-op.
Differences from upstream#
Fully compatible with upstream Digest::MD5 2.58.
See also#
new— the other end of the lifecycleclone— each clone carries its own buffer and its ownDESTROYreset— avoid destruction entirely by reusing the context