On 2/24/26 4:36 AM, Michael Paquier wrote:
> On Mon, Feb 23, 2026 at 03:17:52AM +0100, Andreas Karlsson wrote:
>> Looks like a nice change but why not just fix all instances of it in one
>> swoop? It cannot be that many as there are 166 calls to pg_malloc() and 62
>> calls to pg_malloc0() after your patch that need to be looked at.
>
> FWIW, I don't really mind if these changes are proposed gradually, and
> this looked fine enough on its own. So applied.
Fair, here is a patch which should handle all uses in the frontend code
so we follow this pattern consistently to encourage new code to use
these macros.
When doing this I found two things which I am ot sure what the cleanest
way to handle would be so I broke them out into separate patches.
1. What should we do about when we allocate a an array of characters?
Would it make sense to use pg_array_alloc() or would that jsut be silly?
For example:
-pad = (char *) pg_malloc(l + 1);
+pad = pg_malloc_array(char, l + 1);
2. I found a small and harmless thinko. The buffer in verify_tar_file()
is actually a char * but for some reason the code did the following:
buffer = pg_malloc(READ_CHUNK_SIZE * sizeof(uint8));
What should we do about it? Just skip the "sizof(uint8)"?
Andreas