Re: Avoid unecessary MemSet call (src/backend/utils/cache/relcache.c)

Поиск
Список
Период
Сортировка
От Ranier Vilela
Тема Re: Avoid unecessary MemSet call (src/backend/utils/cache/relcache.c)
Дата
Msg-id CAEudQAquRs=v+Azo=RFn8b18SSFquREwuuR5fk6s9Bga2So2+Q@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Avoid unecessary MemSet call (src/backend/utils/cache/relcache.c)  (David Zhang <david.zhang@highgo.ca>)
Список pgsql-hackers
Em sex., 19 de ago. de 2022 às 19:27, David Zhang <david.zhang@highgo.ca> escreveu:

Hi Ranier,

Hi David,


Following the comment in commit 9fd45870c1436b477264c0c82eb195df52bc0919,

    (The same could be done with appropriate memset() calls, but this
    patch is part of an effort to phase out MemSet(), so it doesn't touch
    memset() calls.)


Should these obviously possible replacement of the standard library function "memset" be considered as well?

 Yes, sure.
In modern C compilers like clang above 13, gcc and msvc the initialization with {0},
has no problem, because all bits are correctly initialized to zero.

However with some old compilers, such behavior is not strictly followed, so with structs it is not safe to use.
But especially for arrays, whose use doesn't depend on filling the holes, it's certainly safe and cheap to use,
which is the case here.

For example, something like the attached one which is focusing on the pageinspect extension only.

Surely you did, but it has to be said, it was compiled and tested with at least a make check.
Looks like it's ok, LTGM. 

regards,
Ranier Vilela

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

Предыдущее
От: Ranier Vilela
Дата:
Сообщение: Re: Fix typo with logical connector (src/backend/commands/vacuumparallel.c)
Следующее
От: Julien Rouhaud
Дата:
Сообщение: Re: Schema variables - new implementation for Postgres 15