Re: Minor refactorings to eliminate some static buffers - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: Minor refactorings to eliminate some static buffers
Date
Msg-id 2f6690c9-0ef7-43c6-9336-a55c3c5c7111@iki.fi
Whole thread Raw
In response to Re: Minor refactorings to eliminate some static buffers  (Peter Eisentraut <peter@eisentraut.org>)
List pgsql-hackers
On 06/08/2024 23:41, Peter Eisentraut wrote:
> On 06.08.24 17:13, Heikki Linnakangas wrote:
>   > --- a/src/backend/access/transam/xlogprefetcher.c
>   > +++ b/src/backend/access/transam/xlogprefetcher.c
>   > @@ -362,7 +362,7 @@ XLogPrefetcher *
>   >  XLogPrefetcherAllocate(XLogReaderState *reader)
>   >  {
>   >         XLogPrefetcher *prefetcher;
>   > -       static HASHCTL hash_table_ctl = {
>   > +       const HASHCTL hash_table_ctl = {
> 
> Is there a reason this is not changed to
> 
> static const HASHCTL ...
> 
> ?  Most other places where changed in that way.

No particular reason. Grepping for HASHCTL's, this is actually different 
from all other uses of HASHCTL and hash_create. All others use a plain 
local variable, and fill the fields like this:

         HASHCTL         hash_ctl;

         hash_ctl.keysize = sizeof(missing_cache_key);
         hash_ctl.entrysize = sizeof(missing_cache_key);
         hash_ctl.hcxt = TopMemoryContext;
         hash_ctl.hash = missing_hash;
         hash_ctl.match = missing_match;

I think that's just because we haven't allowed C99 designated 
initializers for very long.

-- 
Heikki Linnakangas
Neon (https://neon.tech)




pgsql-hackers by date:

Previous
From: Jeff Davis
Date:
Subject: Remaining dependency on setlocale()
Next
From: Tom Lane
Date:
Subject: Re: Remaining dependency on setlocale()