Re: Fix and improve allocation formulas

From: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Fix and improve allocation formulas
Date: 2025-12-17 09:24:31
Message-ID: aUJ2zxgPCaVsVi2a@ip-10-97-1-34.eu-west-3.compute.internal
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Wed, Dec 17, 2025 at 05:19:33PM +0900, Michael Paquier wrote:
> On Thu, Dec 11, 2025 at 01:27:56PM +0000, Bertrand Drouvot wrote:

> diff --git a/src/bin/pg_verifybackup/pg_verifybackup.c b/src/bin/pg_verifybackup/pg_verifybackup.c
> index c9b24df7c05..1cd5fa791c0 100644
> --- a/src/bin/pg_verifybackup/pg_verifybackup.c
> +++ b/src/bin/pg_verifybackup/pg_verifybackup.c
> @@ -1007,7 +1007,7 @@ verify_tar_file(verifier_context *context, char *relpath, char *fullpath,
> return;
> }
>
> - buffer = pg_malloc(READ_CHUNK_SIZE * sizeof(uint8));
> + buffer = pg_malloc(READ_CHUNK_SIZE * sizeof(char));
>
> /* Perform the reads */
> while ((rc = read(fd, buffer, READ_CHUNK_SIZE)) > 0)
>
> This one reads the same to me, still it seems to me that the intention
> is to deal with a byte array. Doesn't this point to the fact that
> using uint8 is more adapted for the astreamer code, following changes
> like b28c59a6cd08? That would be a more invasive change, of course.

While I think that would make sense to follow the b28c59a6cd08 approach, that would
create a huge cascade of changes. For example, astreamer_recovery_injector_content()
passes mystreamer->recoveryconfcontents->data to astreamer_content() with recoveryconfcontents
being a PQExpBuffer and:

typedef struct PQExpBufferData
{
char *data;
...

I'd vote for just changing the palloc() like proposed in v1.

Regards,

--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2025-12-17 09:25:50 Re: Buffer locking is special (hints, checksums, AIO writes)
Previous Message Amit Kapila 2025-12-17 09:13:42 Re: Replace is_publishable_class() with relispublishable column in pg_class