git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Elijah Newren <newren@gmail.com>
To: "René Scharfe" <l.s.r@web.de>
Cc: Git List <git@vger.kernel.org>
Subject: Re: [PATCH] fast-import: use mem_pool_calloc()
Date: Tue, 26 Dec 2023 11:22:51 -0800	[thread overview]
Message-ID: <CABPp-BFcUdheVde6-uFjtwC4ZAmVxJe6SOMTOwRRWDBqOT=DvA@mail.gmail.com> (raw)
In-Reply-To: <50c1f410-ca37-4c1c-a28b-3e9fad49f2b4@web.de>

On Tue, Dec 26, 2023 at 12:18 AM René Scharfe <l.s.r@web.de> wrote:
>
> Use mem_pool_calloc() to get a zeroed buffer instead of zeroing it
> ourselves.  This makes the code clearer and less repetitive.
>
> Signed-off-by: René Scharfe <l.s.r@web.de>
> ---
>  builtin/fast-import.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/builtin/fast-import.c b/builtin/fast-import.c
> index 444f41cf8c..92eda20683 100644
> --- a/builtin/fast-import.c
> +++ b/builtin/fast-import.c
> @@ -2809,8 +2809,7 @@ static void parse_new_tag(const char *arg)
>         enum object_type type;
>         const char *v;
>
> -       t = mem_pool_alloc(&fi_mem_pool, sizeof(struct tag));
> -       memset(t, 0, sizeof(struct tag));
> +       t = mem_pool_calloc(&fi_mem_pool, 1, sizeof(struct tag));
>         t->name = mem_pool_strdup(&fi_mem_pool, arg);
>         if (last_tag)
>                 last_tag->next_tag = t;
> --
> 2.43.0

Makes sense; looks good to me.

      reply	other threads:[~2023-12-26 19:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-26  8:17 [PATCH] fast-import: use mem_pool_calloc() René Scharfe
2023-12-26 19:22 ` Elijah Newren [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CABPp-BFcUdheVde6-uFjtwC4ZAmVxJe6SOMTOwRRWDBqOT=DvA@mail.gmail.com' \
    --to=newren@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=l.s.r@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).