Re: Use C11 alignas instead of palloc/malloc for alignment

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Use C11 alignas instead of palloc/malloc for alignment
Date: 2026-09-08 14:05:08
Message-ID: 82911470-b0ce-402c-b5bf-725dd1f7d0c2@dunslane.net
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 2026-09-08 Tu 6:08 AM, 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.
>
> One of these revealed a small problem with how pgindent handles
> alignas (it doesn't know about it and it might or might not work well
> depending on context), so I added a workaround into pgindent to fix
> that.  (Or we could try to reshuffle that code to avoid the problem.)

The pgindent recipe should possibly be hardened for things like nested
parens. Here's a reworked patch 2.

cheers

andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com

Attachment Content-Type Size
v2-0002-pgindent-Fix-indentation-of-alignas-in-struct-mem.patch text/x-patch 2.8 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2026-09-08 14:08:16 Re: Assert failure in try_nestloop_path()
Previous Message Ayush Tiwari 2026-09-08 13:58:51 Re: Concurrent DROP TABLESPACE can miss a shared dependency