httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Eissing <stefan.eiss...@greenbytes.de>
Subject Re: svn commit: r1712782 - in /httpd/httpd/trunk/modules/http2: h2_session.c h2_stream_set.c h2_stream_set.h h2_version.h
Date Thu, 05 Nov 2015 16:20:56 GMT
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 <ylavic.dev@gmail.com>:
> 
> On Thu, Nov 5, 2015 at 5:03 PM, Yann Ylavic <ylavic.dev@gmail.com> wrote:
>> On Thu, Nov 5, 2015 at 3:21 PM,  <icing@apache.org> 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;
> ...


Mime
View raw message