Re: Use C11 alignas instead of palloc/malloc for alignment - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: Use C11 alignas instead of palloc/malloc for alignment
Date
Msg-id 9e81a344-b927-41e2-acea-da444a03aaa0@eisentraut.org
Whole thread
Responses Re: Use C11 alignas instead of palloc/malloc for alignment
List pgsql-hackers
On 08.09.26 12:08, Peter Eisentraut wrote:
> There are a number of places where palloc()/malloc()/etc. was used 
> solely to obtain an aligned buffer.  We can do these much simpler by 
> using alignas with a local variable instead.  See attached patch.

Here is a new patch set that aims to address all the comments.

First of all, while changing this to make use of the existing 
"AlignedBlock" types, I noticed that PGAlignedXLogBlock is misnamed: It 
should be PGIOAlignedXLogBlock, to maintain the similarity with 
PGAlignedBlock and PGIOAlignedBlock, respectively.  So I'm proposing to 
rename it in patch 0001.

We could then re-introduce the "correct" PGAlignedXLogBlock and make use 
of it, which is patch 0003. But I'm hesitant to change the meaning of 
PGAlignedXLogBlock without some gap in between, so I'm not sure about 
this patch.

Patch 0002 is as before, but with the "AlignedBlock" types used, and the 
copy_file() change backed out and a comment added.

Patch 0004 adds some comments and an assertion for HEADER_SCRATCH_SIZE, 
and patch 0005 refactors things to convert the workspace from static 
variable to a normal (non-static) local variable.  (This could be 
squashed into 0002, but it seems cleaner to review this way at least.)

(The pgindent changes were already committed separately.)

Attachment

pgsql-hackers by date:

Previous
From: shveta malik
Date:
Subject: Re: [PATCH] Release replication slot on error in SQL-callable slot functions
Next
From: Manuel Reyes Bravo
Date:
Subject: Re: Distinguish publication exclusions in object addresses