On Thu, Nov 5, 2015 at 5:03 PM, Yann Ylavic <[email protected]> wrote:
> On Thu, Nov 5, 2015 at 3:21 PM,  <[email protected]> wrote:
>>
>> -h2_stream_set *h2_stream_set_create(apr_pool_t *pool)
>> +static unsigned int stream_hash(const char *key, apr_ssize_t *klen)
>> +{
>> +    /* we use the "int stream_id" has key, which always odd from
>> +    * client and even from server. As long as we do not mix them
>> +    * in one set, snip off the lsb. */
>> +    return (unsigned int)(*((int*)key)) >> 1;
>
> This may cause alignment issues, 'key' is not necessarily int or word
> aligned here.
> You possibly should go for something like:
>   apr_uint32_r k =
>       (key[0] << 0)  |
>       (key[1] << 8)  |
>       (key[2] << 16) |
>       (key[3] << 24) ;

Or maybe simply:
  memcpy(&k, key, 4);
  return k;
...

Reply via email to