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

Поиск
Список
Период
Сортировка
От Justin Pryzby
Тема Re: Avoid unecessary MemSet call (src/backend/utils/cache/relcache.c)
Дата
Msg-id 20220517231855.GG19626@telsasoft.com
обсуждение исходный текст
Ответ на Re: Avoid unecessary MemSet call (src/backend/utils/cache/relcache.c)  (Ranier Vilela <ranier.vf@gmail.com>)
Ответы Re: Avoid unecessary MemSet call (src/backend/utils/cache/relcache.c)  (Ranier Vilela <ranier.vf@gmail.com>)
Re: Avoid unecessary MemSet call (src/backend/utils/cache/relcache.c)  (Peter Eisentraut <peter.eisentraut@enterprisedb.com>)
Список pgsql-hackers
On Tue, May 17, 2022 at 07:52:30PM -0300, Ranier Vilela wrote:
> I found, I believe, a serious problem of incorrect usage of the memset api.
> Historically, people have relied on using memset or MemSet, using the
> variable name as an argument for the sizeof.
> While it works correctly, for arrays, when it comes to pointers to
> structures, things go awry.

Knowing how sizeof() works is required before using it - the same is true for
pointers.

> So throughout the code there are these misuses.

Why do you think it's a misuse ?

Take the first one as an example.  It says:

        GenericCosts costs;
        MemSet(&costs, 0, sizeof(costs));

You sent a patch to change it to sizeof(GenericCosts).

But it's not a pointer, so they are the same.

Is that true for every change in your patch ?

-- 
Justin



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

Предыдущее
От: Ranier Vilela
Дата:
Сообщение: Re: Avoid unecessary MemSet call (src/backend/utils/cache/relcache.c)
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Avoid unecessary MemSet call (src/backend/utils/cache/relcache.c)