But if I only put them in via sth like:

void h2_stream_set_add(h2_stream_set *sp, h2_stream *stream)
{
    apr_hash_set(sp->hash, &stream->id, sizeof(stream->id), stream);
}

the (int*) conversion to (void*) and back to (int*) should not hurt. Or?

It's the only way I access the hash and its not visible outside that file...

//Stefan


> Am 05.11.2015 um 17:07 schrieb Yann Ylavic <[email protected]>:
> 
> 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