summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2015-10-30 20:55:40 +0000
committerSteve Hay <steve.m.hay@googlemail.com>2015-10-30 20:55:56 +0000
commit426c7a0f52788aa9cf8489e56d18e1b9ca0ba8ae (patch)
treed3692177a6cb82b72eb00c0f369470e4155a0d46
parentc1bf118a5deba9cc9e4bba91f1702806ff4e6f4a (diff)
downloadperl-426c7a0f52788aa9cf8489e56d18e1b9ca0ba8ae.tar.gz
Improve pod for [ah]v_(clear|undef)
See [perl #117341]. (cherry picked from commit a4395ebabc865511588235b5953dce6cc458ed3c)
-rw-r--r--av.c22
-rw-r--r--hv.c10
2 files changed, 19 insertions, 13 deletions
diff --git a/av.c b/av.c
index 2d9717a55f..90e26af92e 100644
--- a/av.c
+++ b/av.c
@@ -432,11 +432,15 @@ Perl_av_make(pTHX_ SSize_t size, SV **strp)
/*
=for apidoc av_clear
-Clears an array, making it empty. Does not free the memory the av uses to
-store its list of scalars. If any destructors are triggered as a result,
-the av itself may be freed when this function returns.
+Frees the all the elements of an array, leaving it empty.
+The XS equivalent of C<@array = ()>. See also L</av_undef>.
-Perl equivalent: C<@myarray = ();>.
+Note that it is possible that the actions of a destructor called directly
+or indirectly by freeing an element of the array could cause the reference
+count of the array itself to be reduced (e.g. by deleting an entry in the
+symbol table). So it is a possibility that the AV could have been freed
+(or even reallocated) on return from the call unless you hold a reference
+to it.
=cut
*/
@@ -496,9 +500,13 @@ Perl_av_clear(pTHX_ AV *av)
/*
=for apidoc av_undef
-Undefines the array. Frees the memory used by the av to store its list of
-scalars. If any destructors are triggered as a result, the av itself may
-be freed.
+Undefines the array. The XS equivalent of C<undef(@array)>.
+
+As well as freeing all the elements of the array (like C<av_clear()>), this
+also frees the memory used by the av to store its list of scalars.
+
+See L</av_clear> for a note about the array possibly being invalid on
+return.
=cut
*/
diff --git a/hv.c b/hv.c
index e5bf629b4a..3e3710e689 100644
--- a/hv.c
+++ b/hv.c
@@ -1595,8 +1595,8 @@ Perl_hv_delayfree_ent(pTHX_ HV *hv, HE *entry)
Frees the all the elements of a hash, leaving it empty.
The XS equivalent of C<%hash = ()>. See also L</hv_undef>.
-If any destructors are triggered as a result, the hv itself may
-be freed.
+See L</av_clear> for a note about the hash possibly being invalid on
+return.
=cut
*/
@@ -1829,10 +1829,8 @@ Undefines the hash. The XS equivalent of C<undef(%hash)>.
As well as freeing all the elements of the hash (like hv_clear()), this
also frees any auxiliary data and storage associated with the hash.
-If any destructors are triggered as a result, the hv itself may
-be freed.
-
-See also L</hv_clear>.
+See L</av_clear> for a note about the hash possibly being invalid on
+return.
=cut
*/