Re: [PATCH] dynahash: add memory allocation failure check - Mailing list pgsql-hackers

From Andrey Borodin
Subject Re: [PATCH] dynahash: add memory allocation failure check
Date
Msg-id E48561A7-85E0-4646-9C19-437ACBE291BC@yandex-team.ru
Whole thread Raw
In response to Re: [PATCH] dynahash: add memory allocation failure check  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: [PATCH] dynahash: add memory allocation failure check
List 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 by date:

Previous
From: Jelte Fennema-Nio
Date:
Subject: Re: What's our minimum supported Python version?
Next
From: Peter Eisentraut
Date:
Subject: Re: Enable data checksums by default