@@ -418,45 +418,49 @@ valid precomputed hash value, or 0 to ask for it to be computed.
418418
419419=for apidoc hv_fetch
420420=for apidoc_item hv_fetchs
421+ =for apidoc_item hv_fetch_ent
421422
422- These each return the SV which corresponds to the specified key in the hash.
423- They differ only in how the key is specified.
423+ These each return the value entry in a hash which corresponds to the specified
424+ key.
425+
426+ In all, if <hv> is NULL, NULL is returned.
427+
428+ They differ principally in how the key is specified, and the form of the return.
424429
425430In C<hv_fetchs>, the key must be a C language string literal, enclosed in
426431double quotes. It is never treated as being in UTF-8. There is no
427432length_parameter.
428433
429- In C<hv_fetch>, the absolute value of C<klen> is the length of the key. If
430- C<klen> is negative the key is assumed to be in UTF-8-encoded Unicode.
431- C<key> may contain embedded NUL characters.
434+ In C<hv_fetch>, C<key> is either NULL or points to the first byte of the string
435+ specifying the key, and its length in bytes is given by the absolute value of
436+ an additional parameter, C<klen>. A NULL key indicates the key is to be
437+ treated as C<undef>, and C<klen> is ignored. A non-NULL C<key> may contain
438+ embedded-NUL characters. If C<klen> is negative, C<key> is treated as being
439+ encoded in UTF-8; otherwise not.
432440
433- In both, if C<lval> is set, then the fetch will be part of a store. This means
434- that if there is no value in the hash associated with the given key, then one
435- is created and a pointer to it is returned. The C<SV*> it points to can be
436- assigned to. But always check that the return value is non-null before
437- dereferencing it to an C<SV*>.
441+ In C<hv_fetch_ent>, the key is stored in the SV C<keysv> which this function
442+ extracts using C<L</SvPV_const>>. The key has the same UTF8ness as C<keysv>.
438443
439- See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for more
440- information on how to use this function on tied hashes .
444+ The value entry returned by C<hv_fetch> and C<hv_fetchs> is an SV**. Always
445+ check that the return value is non-null before dereferencing it to an C<SV*> .
441446
442- =cut
443- */
447+ The value entry returned by C<hv_fetch_ent> is a pointer to a
448+ L<C<HE>|perlguts/Working with HVs> structure with the all fields set. When
449+ C<hv> is a tied hash, the HE structure is in a static location, so be sure to
450+ make a copy of the structure if you need to store it somewhere. Also, for
451+ MAGICAL hashes, the C<hent_val> field in the returned HE structure will be a
452+ mortal sv.
444453
445- /* returns an HE * structure with the all fields set */
446- /* note that hent_val will be a mortal sv for MAGICAL hashes */
447- /*
448- =for apidoc hv_fetch_ent
449-
450- Returns the hash entry which corresponds to the specified key in the hash.
451- C<hash> must be a valid precomputed hash number for the given C<key>, or 0
452- if you want the function to compute it. IF C<lval> is set then the fetch
453- will be part of a store. Make sure the return value is non-null before
454- accessing it. The return value when C<hv> is a tied hash is a pointer to a
455- static location, so be sure to make a copy of the structure if you need to
456- store it somewhere.
454+ In all, if C<lval> is non-zero, then the fetch will be part of a store. This
455+ means that if there is no value in the hash associated with the given key,
456+ then a SV* is created, accessible through the returned value.
457457
458458See L<perlguts/"Understanding the Magic of Tied Hashes and Arrays"> for more
459- information on how to use this function on tied hashes.
459+ information on how to use these functions on tied hashes.
460+
461+ C<hv_fetch_ent> has an additional parameter, C<hash>. It must be a valid
462+ precomputed hash number for the given C<key>, or 0 if you want the function to
463+ compute it.
460464
461465=cut
462466*/
0 commit comments