[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: FSFS/svn-rep-sharing-stats questions

From: Branko Cibej <brane_at_xbc.nu>
Date: Tue, 13 Oct 2009 04:39:28 +0200

Daniel Shahaf wrote:
> David Glasser wrote on Mon, 12 Oct 2009 at 16:54 -0700:
>
>> Also, I'm not really sure that casting unsigned int<->void* is
>> technically well-defined.
>>
It's not, quite ...

> Was trying to avoid malloc'ing an unsigned int. But, indeed, I can't
> find a reference allowing the cast. So I have two options:
>
> * malloc an unsigned int
>
> * use pointer arithmetic:
> def increment():
> void *p = apr_hash_get();
> apr_hash_set(p+1)
> def extract_final_value():
> void *p = apr_hash_get();
> return (p - NULL)
>

Which is not strictly well-defined, either. :) void* doesn't have a
size, so you can't do arithmetic with it (never mind GCC's extension).

> I'll go with the first option :)
>

However from a *practical* standpoint:

    * C99 defines the types intptr_t and uintptr_t which are integer
      types guaranteed to be large enough to store a void*'s value
      without data loss;
    * We don't use C99, but if you let configure find an appropriate
      integer type, or use ptrdiff_t, it'll work for all practical
      purposes since you control what goes in the hash.
    * You could always do your counting with char* ...

-- Brane

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2406900
Received on 2009-10-13 23:14:36 CEST

This is an archived mail posted to the Subversion Dev mailing list.