Re: [PATCH v10] git: use calloc instead of malloc + memset where possible
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Dec 18, 2024, 15:39 UTC
- Message-ID
- <xmqqr065t2yp.fsf@gitster.g>
- In-Reply-To
- <pull.1390.v10.git.git.1734485187081.gitgitgadget@gmail.com>
"AreaZR via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 5 quoted lines
> From: Seija Kijin <doremylover123@gmail.com> > > Avoid calling malloc + memset by calling calloc. > > Signed-off-by: Seija <doremylover123@gmail.com>
Name mismatch.
> remote.c | 4 ++-- > submodule.c | 10 +++++----- > 2 files changed, 7 insertions(+), 7 deletions(-)
I somehow hoped to see that this shrinks the line count, as you are essentially replacing two calls (malloc + memset) with one, but that is not what is happening, which is a bit disapointing.
But this is a strict improvement, I guess. The reader needs to be familiar with the CALLOC_ARRAY() macro to understand it, which may make the code less newbie-friendly (as opposed to malloc+memset any reasonably competent C programmer would understand without any prior knowledge of the conventions used by this project).