develooper Front page | perl.perl5.porters | Postings from September 2016

Re: hv.h hek definition

Thread Previous | Thread Next
Father Chrysostomos
September 29, 2016 03:27
Re: hv.h hek definition
Message ID:
Todd Rinaldo wrote:
> IMO, the declaration for hek_key is VERY misleading. In the context of a
> struct, what you end up with when you do char hek_key[1]; is a char
> pointer followed by a char.

char hek_key[1] stores the char array's members directly in the
struct.  There is no pointer stored in the struct.

> This seems
> much more intuitive and legible:
> struct hek
> {
>    U32 hek_hash;               /* hash of key */
>    I32 hek_len;                /* length of hash key */
>    char *hek_key;            /* hash key pointer */
>    char flags;     /* hek flags such as whether the key is UTF-8 */
> };

That variant does store a pointer in the struct and would require the
key to be allocated as a separate buffer.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About