Re: Use C11 alignas instead of palloc/malloc for alignment
Re: Use C11 alignas instead of palloc/malloc for alignment
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
Re: Use C11 alignas instead of palloc/malloc for alignment
От:
Peter Eisentraut <peter@eisentraut.org>
Дата:
On 08.09.26 16:05, Andrew Dunstan wrote: > > 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. Thanks, this is a clever solution. I have committed this separately.