| From: | Thorsten Glaser <tg(at)evolvis(dot)org> |
|---|---|
| To: | pgsql-general(at)lists(dot)postgresql(dot)org |
| Cc: | Wen Yi <chuxuec(at)outlook(dot)com> |
| Subject: | Re: Why not use the calloc to replace malloc? |
| Date: | 2023-04-23 14:21:48 |
| Message-ID: | 41c9d7f-7953-d22c-12f1-e83815cb5d9e@evolvis.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Sat, 22 Apr 2023, Tom Lane wrote:
>Wen Yi <chuxuec(at)outlook(dot)com> writes:
>> [ use calloc to replace zeroing fields individually ]
[…]
>People have complained about this practice off-and-on, but no one has
>provided any evidence that there's a significant performance cost.
>The maintenance benefits are real though.
Oh, interesting ;-) Thanks for this explanation.
Another data point is: calloc is not correct for pointer fields,
you have to manually assign NULL to them afterwards still, because
NULL doesn’t have to be represented by all-zero bytes (e.g. TenDRA
supports having 0x55555555 as NULL pointer as an option).
bye,
//mirabilos
--
15:41⎜<Lo-lan-do:#fusionforge> Somebody write a testsuite for helloworld :-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2023-04-23 15:04:21 | Re: Why not use the calloc to replace malloc? |
| Previous Message | Tom Lane | 2023-04-23 03:59:37 | Re: Why not use the calloc to replace malloc? |