Subject: | HEK for hash stash name introduced in 5.9.3, not 5.13/5.14 |
----------------------------------------------------
NAME:
Until 5.14 NAME was a NUL-terminated string which denotes the fully qualified name of the name space (aka package). This was one of the few places where Perl does not allow strings with embedded NULs. Since 5.14 the value of NAME points to a HEK if name_count == 0, or to two HEKs, where HEK[0] is the effective stash name (HvENAME_HEK_NN) if name_count > 0 or HEK[1] if name_count < 0.
----------------------------------------------------
This is wrong.
From 5.12
----------------------------------------------------
struct xpvhv_aux {
HEK *xhv_name; /* name, if a symbol table */
AV *xhv_backreferences; /* back references for weak references */
HE *xhv_eiter; /* current entry of iterator */
I32 xhv_riter; /* current root of iterator */
struct mro_meta *xhv_mro_meta;
};
----------------------------------------------------
from 5.10
----------------------------------------------------
struct xpvhv_aux {
HEK *xhv_name; /* name, if a symbol table */
AV *xhv_backreferences; /* back references for weak references */
HE *xhv_eiter; /* current entry of iterator */
I32 xhv_riter; /* current root of iterator */
struct mro_meta *xhv_mro_meta;
};
----------------------------------------------------
from 5.6
----------------------------------------------------
/* hash structure: */
/* This structure must match the beginning of struct xpvmg in sv.h. */
struct xpvhv {
char * xhv_array; /* pointer to malloced string */
STRLEN xhv_fill; /* how full xhv_array currently is */
STRLEN xhv_max; /* subscript of last element of xhv_array */
IV xhv_keys; /* how many elements in the array */
NV xnv_nv; /* numeric value, if any */
MAGIC* xmg_magic; /* magic for scalar array */
HV* xmg_stash; /* class package */
I32 xhv_riter; /* current root of iterator */
HE *xhv_eiter; /* current entry of iterator */
PMOP *xhv_pmroot; /* list of pm's for this package */
char *xhv_name; /* name, if a symbol table */
};
------------------------------------------------------
The commit where it went from char * to HEK * http://perl5.git.perl.org/perl.git/commit/7423f6db106ad471398838e82e73b22d8c1e166e which happened in 5.9.2/5.9.3 range.
For comparison 5.19 is
-------------------------------------------------------
union _xhvnameu {
HEK *xhvnameu_name; /* When xhv_name_count is 0 */
HEK **xhvnameu_names; /* When xhv_name_count is non-0 */
};
struct xpvhv_aux {
union _xhvnameu xhv_name_u; /* name, if a symbol table */
AV *xhv_backreferences; /* back references for weak references */
HE *xhv_eiter; /* current entry of iterator */
I32 xhv_riter; /* current root of iterator */
/* Concerning xhv_name_count: When non-zero, xhv_name_u contains a pointer
* to an array of HEK pointers, this being the length. The first element is
* the name of the stash, which may be NULL. If xhv_name_count is positive,
* then *xhv_name is one of the effective names. If xhv_name_count is nega-
* tive, then xhv_name_u.xhvnameu_names[1] is the first effective name.
*/
I32 xhv_name_count;
struct mro_meta *xhv_mro_meta;
#ifdef PERL_HASH_RANDOMIZE_KEYS
U32 xhv_rand; /* random value for hash traversal */
U32 xhv_last_rand; /* last random value for hash traversal,
used to detect each() after insert for warnings */
#endif
U32 xhv_fill_lazy;
};
---------------------------------------------------------