Re: Consistently use palloc_object() and palloc_array() - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Consistently use palloc_object() and palloc_array()
Date
Msg-id 32295.1764213912@sss.pgh.pa.us
Whole thread Raw
In response to Re: Consistently use palloc_object() and palloc_array()  (Thomas Munro <thomas.munro@gmail.com>)
Responses Re: Consistently use palloc_object() and palloc_array()
List pgsql-hackers
Thomas Munro <thomas.munro@gmail.com> writes:
> This isn't a fully-baked thought, just a thought that occurred to me
> while looking into that:  If palloc_object(Int128AggState) were smart
> enough to detect that alignof(T) > MAXALIGN and redirect to
> palloc_aligned(sizeof(T), alignof(T), ...) at compile time, then
> Int128AggState would naturally propagate the layout requirements of
> its __int128 member, and we wouldn't need to do that weird stuff, and
> it wouldn't be error-prone if usage of __int128 spreads to more
> structs.  That really only makes sense if we generalise
> palloc_object() as a programming style and consider direct use of
> palloc() to be a rarer low-level interface that triggers human
> reviewers to think about alignment, I guess.

Hmm ... I had the same doubts as Michael about whether this change
could possibly be worth the ensuing back-patching pain.  But if
it leads to an improvement in type-safety, that'd be a reason to
take on the work.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: [PATCH] contrib: Add pg_datemath extension with datediff function
Next
From: Chao Li
Date:
Subject: Re: IPC/MultixactCreation on the Standby server