Front page | perl.perl5.porters |
Postings from September 2016
Re: hv.h hek definition
Thread Previous
|
Thread Next
From:
Lukas Mai
Date:
September 29, 2016 03:21
Subject:
Re: hv.h hek definition
Message ID:
f997a112-b2c4-0dc1-98e6-0534590b6d5f@gmail.com
Am 29.09.2016 um 04:52 schrieb Todd Rinaldo:
> Excerpt from hv.h:
>
> /* hash key -- defined separately for use as shared pointer */
> struct hek
> {
> U32 hek_hash; /* hash of key */
> I32 hek_len; /* length of hash key */
> char hek_key[1]; /* variable-length hash key */
> /* the hash-key is \0-terminated */
> /* after the \0 there is a byte for flags, such as whether the key
> is UTF-8 */
> };
>
> 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. We exploit that to store the flags
> in thechar slot and we inject a string pointer in hek_key.
That's simply not correct. There is no pointer involved. "char foo[1]"
does not create a pointer followed by a char.
--
Lukas Mai <plokinom@gmail.com>
Thread Previous
|
Thread Next