Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connections
Warning: mysqli::query(): Couldn't fetch mysqli in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\index.php on line 66
Article <v2q6v0$2br8t$1@dont-email.me>
Deutsch   English   Français   Italiano  
<v2q6v0$2br8t$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Malcolm McLean <malcolm.arthur.mclean@gmail.com>
Newsgroups: comp.lang.c
Subject: Re: Good hash for pointers
Date: Fri, 24 May 2024 15:07:28 +0100
Organization: A noiseless patient Spider
Lines: 66
Message-ID: <v2q6v0$2br8t$1@dont-email.me>
References: <v2n88p$1nlcc$1@dont-email.me> <86v834i1o9.fsf@linuxsc.com>
 <v2okbv$1vp4n$2@dont-email.me> <86r0dshysc.fsf@linuxsc.com>
 <v2omvt$2049k$1@dont-email.me> <86ed9shtsj.fsf@linuxsc.com>
 <v2ppac$29ca1$1@dont-email.me> <865xv3ic14.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 24 May 2024 16:07:28 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="b72444689a26009d2960a16da4ad5d91";
	logging-data="2485533"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18xRTac9ZKhAUYN6QHpi2HzJD1Ktw7g4u8="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:59N8v2GlSFnCI495ZL0v8jXQTro=
Content-Language: en-GB
In-Reply-To: <865xv3ic14.fsf@linuxsc.com>
Bytes: 3607

On 24/05/2024 14:18, Tim Rentsch wrote:
> bart <bc@freeuk.com> writes:
> 
>> On 24/05/2024 02:39, Tim Rentsch wrote:
>>
>>> Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:
>>>
>>>> On 24/05/2024 00:52, Tim Rentsch wrote:
>>>>
>>>>> Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:
>>>>>
>>>>>> On 23/05/2024 23:49, Tim Rentsch wrote:
>>>>>>
>>>>>>> Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:
>>>>>>>
>>>>>>>> What is a good hash function for pointers to use in portable
>>>>>>>> ANSI C?
>>>>>>>
>>>>>>> I have a preliminary question.  Do you really mean ANSI C, or
>>>>>>> is C99 acceptable?
>>>>>>
>>>>>> C89 is better.
>>>>>> But the pass has been sold.
>>>>>
>>>>> I'm not asking which you think is better.  I'm asking about
>>>>> what your requirements are.
>>>>
>>>> C 89.
>>>> I don't want to pull in C99 types and so on just for a hash
>>>> function.
>>>
>>> In that case I think you are stuck with using a half-baked
>>> solution.  The standard integer types available in C89 just
>>> aren't a good fit in a 64-bit world.
>>
>> I assume the C89 implementation is one that can target current 64
>> bit machines.
>>
>> Then char, short, int, long long will almost certainly have widths
>> of 8, 16, 32 and 64 bits respectively.
> 
> C89 doesn't have long long.
> 
>> (I don't know if 'long long' was part of C89, but it sounds like
>> Malcolm just doesn't want to be bothered with stdint.h, and any
>> compiler used is like to support it.
> 
> What he said was C89.  He didn't mention stdint.h.  I take
> him at his word.  If what he wants is something different,
> he should say clearly what it is, and not make people guess
> about it.  (To be clear this recommendation is intended for
> every questioner, not just Malcolm.)

cJSON.c is C89. And these additions to the resource compiler were 
inspired by a menntion of cJSON.c here.

So a C89 hash for a pointer to an unsigned int would be ideal. However 
it might be impossible to write one which is both efficient in terms of 
machine instructions and a good hash function in that it distributes the 
hashes evenly given an uneven distribution of keys. And pointers 
returned from repeated calls to malloc() are going to have an odd 
distribution of values.
-- 
Check out Basic Algorithms and my other books:
https://www.lulu.com/spotlight/bgy1mm