Re: Avoid unecessary MemSet call (src/backend/utils/cache/relcache.c)
В списке pgsql-hackers по дате отправления:
| От | Tom Lane |
|---|---|
| Тема | Re: Avoid unecessary MemSet call (src/backend/utils/cache/relcache.c) |
| Дата | |
| Msg-id | 1636334.1652829740@sss.pgh.pa.us обсуждение |
| Ответ на | Re: Avoid unecessary MemSet call (src/backend/utils/cache/relcache.c) (Ranier Vilela <ranier.vf@gmail.com>) |
| Список | pgsql-hackers |
Ranier Vilela <ranier.vf@gmail.com> writes:
> 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.
You'll have to convince people that any of these places are in
fact incorrect. Everyone who's used C for any length of time
is well aware of the possibility of getting sizeof() wrong in
this sort of context, and I think we've been careful about it.
Also, as a stylistic matter I think it's best to write
"memset(&x, 0, sizeof(x))" where we can. Replacing sizeof(x)
with sizeof(some type name) has its own risks of error, and
therefore is not automatically an improvement.
regards, tom lane
В списке pgsql-hackers по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера