git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Stefan Beller <sbeller@google.com>
To: Derrick Stolee <stolee@gmail.com>
Cc: Jeff King <peff@peff.net>, Junio C Hamano <gitster@pobox.com>,
	git <git@vger.kernel.org>
Subject: Re: [PATCH 2/2] replace-object.c: remove the_repository from prepare_replace_object
Date: Thu, 10 May 2018 11:32:37 -0700	[thread overview]
Message-ID: <CAGZ79kb_qLm2dBxDmH7-N9C9+oVArxehTC3RuM7ci292AuFmBQ@mail.gmail.com> (raw)
In-Reply-To: <da155b13-b915-edb7-9bf9-6bef900cdde9@gmail.com>

> Using `git grep` I see 230 instances of 'xmalloc' and 261 instances of
> 'xcalloc'. After the Coccinelle transformation, these are down to 194 and
> 190, respectively, because the rest allocate in the same line as the
> definition. It's worth thinking about the macro pattern for those cases.

Thanks for reporting the coccinelle experiment!

As we follow a strict declare before code, and we do not know if further
declarations make use of this already, e.g. given

    struct foo *f = xmalloc(sizeof(*f));
    struct bar b = &f->baz;

we cannot split up the line declaring and assigning f, but the macro
has to recreate the assignment upon declaration, for that we'd
need to have something like

    ALLOCATE_TYPE(type, name);

which over complicates things IMHO.

Maybe it is worth identifying the pattern where 'f' is not used in further
declarations, such that we can make patches as

-    struct foo *f = xmalloc(sizeof(*f));
+   struct foo *f;
    struct baz b = &unrelated;
+
+ ALLOCATE(f);
+

Thanks,
Stefan

  reply	other threads:[~2018-05-10 18:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-09 23:40 [PATCH 1/2] object.c: free replace map in raw_object_store_clear Stefan Beller
2018-05-09 23:40 ` [PATCH 2/2] replace-object.c: remove the_repository from prepare_replace_object Stefan Beller
2018-05-10 10:23   ` Junio C Hamano
2018-05-10 11:56     ` Jeff King
2018-05-10 14:53       ` Derrick Stolee
2018-05-10 18:32         ` Stefan Beller [this message]
2018-05-10 10:16 ` [PATCH 1/2] object.c: free replace map in raw_object_store_clear Junio C Hamano
2018-05-10 17:23   ` Stefan Beller
  -- strict thread matches above, loose matches on Subject: below --
2018-05-17 18:20 What's cooking in git.git (May 2018, #02; Thu, 17) Stefan Beller
2018-05-17 18:29 ` [PATCH 0/2] Reroll 2 last commits of sb/object-store-replace Stefan Beller
2018-05-17 18:29   ` [PATCH 2/2] replace-object.c: remove the_repository from prepare_replace_object Stefan Beller

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=CAGZ79kb_qLm2dBxDmH7-N9C9+oVArxehTC3RuM7ci292AuFmBQ@mail.gmail.com \
    --to=sbeller@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    --cc=stolee@gmail.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).