Re: Fix and improve allocation formulas - Mailing list pgsql-hackers

From Bertrand Drouvot
Subject Re: Fix and improve allocation formulas
Date
Msg-id aUJ2zxgPCaVsVi2a@ip-10-97-1-34.eu-west-3.compute.internal
Whole thread Raw
In response to Re: Fix and improve allocation formulas  (Michael Paquier <michael@paquier.xyz>)
List 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



pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Replace is_publishable_class() with relispublishable column in pg_class
Next
From: Heikki Linnakangas
Date:
Subject: Re: Buffer locking is special (hints, checksums, AIO writes)