RE: Proposal: Make use of C99 designated initialisers fornulls/values arrays - Mailing list pgsql-hackers

From Smith, Peter
Subject RE: Proposal: Make use of C99 designated initialisers fornulls/values arrays
Date
Msg-id 201DD0641B056142AC8C6645EC1B5F62014B91B2E8@SYD1217
Whole thread Raw
In response to Re: Proposal: Make use of C99 designated initialisers fornulls/values arrays  (Isaac Morland <isaac.morland@gmail.com>)
Responses Re: Proposal: Make use of C99 designated initialisers fornulls/values arrays
List pgsql-hackers
From: Isaac Morland <isaac.morland@gmail.com> Sent: Tuesday, 1 October 2019 11:32 PM

>Typical Example:
>Before:
>        Datum           values[Natts_pg_attribute];
>        bool            nulls[Natts_pg_attribute];
>        ...
>        memset(values, 0, sizeof(values));
>        memset(nulls, false, sizeof(nulls));
>After:
>        Datum           values[Natts_pg_attribute] = {0};
>        bool            nulls[Natts_pg_attribute] = {0};
>
>I hope you'll forgive a noob question. Why does the "After" initialization for the boolean array have {0} rather than
{false}? 

It is a valid question. 

I found that the original memsets that this patch replaces were already using 0 and false interchangeably. So I just
pickedone. 
 
Reasons I chose {0} over {false} are: (a) laziness, and (b) consistency with the values[] initialiser.

But it is no problem to change the bool initialisers to {false} if that becomes a committer review issue.

Kind Regards
--
Peter Smith
Fujitsu Australia

pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: PATCH: logical_work_mem and logical streaming of largein-progress transactions
Next
From: Amit Kapila
Date:
Subject: Re: pgbench - allow to create partitioned tables