[PATCH] Combine malloc + memset to calloc
Iain Buclaw
ibuclaw@gdcproject.org
Mon Nov 15 23:54:28 GMT 2021
Excerpts from Seija K. via Gcc-patches's message of November 12, 2021 9:29 pm:
> diff --git a/gcc/d/dmd/ctfeexpr.c b/gcc/d/dmd/ctfeexpr.c
> index a8e97833ad0..401ed748f43 100644
> --- a/gcc/d/dmd/ctfeexpr.c
> +++ b/gcc/d/dmd/ctfeexpr.c
> @@ -1350,8 +1350,7 @@ int ctfeRawCmp(Loc loc, Expression *e1, Expression
> *e2)
> if (es2->keys->length != dim)
> return 1;
>
> - bool *used = (bool *)mem.xmalloc(sizeof(bool) * dim);
> - memset(used, 0, sizeof(bool) * dim);
> + bool *used = (bool *)mem.xcalloc(dim, sizeof(bool));
>
> for (size_t i = 0; i < dim; ++i)
> {
Hi,
Thanks, however all changes to the dmd front-end should go through
upstream first. But as this file is about to be dropped, I don't
immediately see a need to keep this part in the patch.
Iain.
More information about the Gcc-patches
mailing list