Re: Proposal: Make use of C99 designated initialisers fornulls/values arrays

Поиск
Список
Период
Сортировка
От Amit Kapila
Тема Re: Proposal: Make use of C99 designated initialisers fornulls/values arrays
Дата
Msg-id CAA4eK1+pPoEAN0myq_ohNvY-3fQ2o0TcTezhst74k9tm8s6u8A@mail.gmail.com
обсуждение исходный текст
Ответ на RE: Proposal: Make use of C99 designated initialisers fornulls/values arrays  ("Smith, Peter" <peters@fast.au.fujitsu.com>)
Ответы Re: Proposal: Make use of C99 designated initialisers fornulls/values arrays  (Joe Nelson <joe@begriffs.com>)
RE: Proposal: Make use of C99 designated initialisers fornulls/values arrays  ("Smith, Peter" <peters@fast.au.fujitsu.com>)
Список pgsql-hackers
On Fri, Oct 4, 2019 at 12:10 PM Smith, Peter <peters@fast.au.fujitsu.com> wrote:
From: Tom Lane <tgl@sss.pgh.pa.us> Sent: Friday, 4 October 2019 2:08 PM

>> #define INIT_ALL_ELEMS_ZERO  {0}
>> #define INIT_ALL_ELEMS_FALSE {false}

>I would say that's 100% wrong.  The entire point here is that it's memset-equivalent, and therefore writes zeroes, regardless of what the datatype is. 

I agree it is memset-equivalent.

All examples of the memset code that INIT_ALL_ELEMS_ZERO replaces looked like this:
memset(values, 0, sizeof(values));

Most examples of the memset code that INIT_ALL_ELEMS_FALSE replaces looked like this:
memset(nulls, false, sizeof(nulls));

~

I made the 2nd macro because I anticipate the same folk that don't like setting 0 to a bool will also not like setting something called INIT_ALL_ELEMS_ZERO to a bool array.

How about I just define them both the same?
#define INIT_ALL_ELEMS_ZERO     {0}
#define INIT_ALL_ELEMS_FALSE    {0}


I think using one define would be preferred, but you can wait and see if others prefer defining different macros for the same thing.

--
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com

В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Smith, Peter"
Дата:
Сообщение: RE: Proposal: Make use of C99 designated initialisers fornulls/values arrays
Следующее
От: Tomas Vondra
Дата:
Сообщение: Re: Memory Accounting