Re: [PATCH] dynahash: add memory allocation failure check

Поиск
Список
Период
Сортировка
От Andrey Borodin
Тема Re: [PATCH] dynahash: add memory allocation failure check
Дата
Msg-id E48561A7-85E0-4646-9C19-437ACBE291BC@yandex-team.ru
обсуждение исходный текст
Ответ на Re: [PATCH] dynahash: add memory allocation failure check  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: [PATCH] dynahash: add memory allocation failure check
Список pgsql-hackers

> On 24 Apr 2025, at 00:42, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> - hashp = (HTAB *) DynaHashAlloc(sizeof(HTAB) + strlen(tabname) + 1);
> + hashp = (HTAB *) MemoryContextAlloc(CurrentDynaHashCxt,
> + sizeof(HTAB) + strlen(tabname) + 1);

This seems correct to me.

While fixing this maybe use MemoryContextAllocZero() instead of subsequent MemSet()?

But this might unroll loop of unnecessary beautifications like DynaHashAlloc() calling
Assert(MemoryContextIsValid(CurrentDynaHashCxt))just before MemoryContextAllocExtended() will repeat same exercise. 


Best regards, Andrey Borodin.


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