Re: Why not use the calloc to replace malloc? - Mailing list pgsql-general

From Thorsten Glaser
Subject Re: Why not use the calloc to replace malloc?
Date
Msg-id 41c9d7f-7953-d22c-12f1-e83815cb5d9e@evolvis.org
Whole thread Raw
In response to Re: Why not use the calloc to replace malloc?  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Why not use the calloc to replace malloc?
List pgsql-general
On Sat, 22 Apr 2023, Tom Lane wrote:

>Wen Yi <chuxuec@outlook.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 :-)



pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Why not use the calloc to replace malloc?
Next
From: Tom Lane
Date:
Subject: Re: Why not use the calloc to replace malloc?