diff options
-rw-r--r-- | lib/Internals.pod | 9 | ||||
-rw-r--r-- | t/lib/universal.t | 2 | ||||
-rw-r--r-- | universal.c | 15 |
3 files changed, 26 insertions, 0 deletions
diff --git a/lib/Internals.pod b/lib/Internals.pod index 28f6711b30..4a1144afd6 100644 --- a/lib/Internals.pod +++ b/lib/Internals.pod @@ -6,6 +6,7 @@ Internals - Reserved special namespace for internals related functions $is_ro= Internals::SvREADONLY($x) $refcnt= Internals::SvREFCNT($x) + hv_clear_placeholders(%hash); =head1 DESCRIPTION @@ -55,6 +56,12 @@ to implement higher-level behavior which should be used instead. See the core implementation for the exact meaning of the readonly flag for each internal variable type. +=item hv_clear_placeholders(%hash) + +Clear any placeholders from a locked hash. Should not be used directly. +You should use the wrapper functions providewd by Hash::Util instead. +As of 5.25 also available as C< Hash::Util::_clear_placeholders(%hash) > + =back =head1 AUTHOR @@ -64,6 +71,8 @@ Perl core development team. =head1 SEE ALSO L<perlguts> +L<Hash::Util> +L<constant> universal.c =cut diff --git a/t/lib/universal.t b/t/lib/universal.t index feb3db98b9..5980cade35 100644 --- a/t/lib/universal.t +++ b/t/lib/universal.t @@ -14,9 +14,11 @@ for my $arg ('', 'q[]', qw( 1 undef )) { sub tryit { eval shift or warn \$@ } tryit "&Internals::SvREADONLY($arg)"; tryit "&Internals::SvREFCNT($arg)"; +tryit "&Internals::hv_clear_placeholders($arg)"; ---- Usage: Internals::SvREADONLY(SCALAR[, ON]) at (eval 1) line 1. Usage: Internals::SvREFCNT(SCALAR[, REFCOUNT]) at (eval 2) line 1. +Usage: Internals::hv_clear_placeholders(hv) at (eval 3) line 1. ==== } diff --git a/universal.c b/universal.c index e77fad3605..174003105f 100644 --- a/universal.c +++ b/universal.c @@ -627,6 +627,20 @@ XS(XS_Internals_SvREFCNT) /* This is dangerous stuff. */ } +XS(XS_Internals_hv_clear_placehold); /* prototype to pass -Wmissing-prototypes */ +XS(XS_Internals_hv_clear_placehold) +{ + dXSARGS; + + if (items != 1 || !SvROK(ST(0))) + croak_xs_usage(cv, "hv"); + else { + HV * const hv = MUTABLE_HV(SvRV(ST(0))); + hv_clear_placeholders(hv); + XSRETURN(0); + } +} + XS(XS_PerlIO_get_layers); /* prototype to pass -Wmissing-prototypes */ XS(XS_PerlIO_get_layers) { @@ -1002,6 +1016,7 @@ static const struct xsub_details details[] = { {"utf8::unicode_to_native", XS_utf8_unicode_to_native, NULL}, {"Internals::SvREADONLY", XS_Internals_SvREADONLY, "\\[$%@];$"}, {"Internals::SvREFCNT", XS_Internals_SvREFCNT, "\\[$%@];$"}, + {"Internals::hv_clear_placeholders", XS_Internals_hv_clear_placehold, "\\%"}, {"constant::_make_const", XS_constant__make_const, "\\[$@]"}, {"PerlIO::get_layers", XS_PerlIO_get_layers, "*;@"}, {"re::is_regexp", XS_re_is_regexp, "$"}, |