| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Andres Freund <andres(at)anarazel(dot)de> |
| Cc: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: Fix and improve allocation formulas |
| Date: | 2025-12-11 16:43:27 |
| Message-ID: | 838071.1765471407@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Andres Freund <andres(at)anarazel(dot)de> writes:
> I tend to agree that what you propose is the better style, but I seriously
> doubt that
> a) changing over everything at once is worth the backpatch hazard and review
> pain
> b) that to judge whether we should do this a 277kB patch is useful
> c) that changing the existing code should be the first thing, if we want to
> make this the new style, we should first document the sizeof(*var) approach to
> be preferred.
And before that, you'd have to get consensus that sizeof(*var) *is*
the preferred style. I for one don't like it a bit. IMO what it
mostly accomplishes is to remove a cue as to what we are allocating.
I don't agree that it removes a chance for error, either. Sure,
if you write
foo = palloc(sizeof(typeA))
when foo is of type typeB*, you made a mistake --- but we know how
to get the compiler to warn about such mistakes, and indeed the
main point of the palloc_object() changes was to catch those.
However, suppose you write
foo = palloc(sizeof(*bar))
I claim that's about an equally credible typo, and there is
nothing that will detect it.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Álvaro Herrera | 2025-12-11 16:56:13 | Re: Fix and improve allocation formulas |
| Previous Message | Sami Imseih | 2025-12-11 16:35:41 | Re: Re[2]: [PATCH] Add last_executed timestamp to pg_stat_statements |