git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] replace-object.c: remove the_repository from prepare_replace_object

From
Stefan Beller <sbeller@google.com>
Date
May 10, 2018, 18:32 UTC
Message-ID
<CAGZ79kb_qLm2dBxDmH7-N9C9+oVArxehTC3RuM7ci292AuFmBQ@mail.gmail.com>
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

Previous: Derrick StoleeNext: Junio C Hamano
Message 6 of 8 in “object.c: free replace map in raw_object_store_clear”
  1. 1/2 object.c: free replace map in raw_object_store_clearStefan Beller, May 9, 2018
  2. 2/2 replace-object.c: remove the_repository from prepare_replace_objectStefan Beller, May 9, 2018
  3. Junio C HamanoMay 10, 2018
  4. Jeff KingMay 10, 2018
  5. Derrick StoleeMay 10, 2018
  6. Stefan BellerMay 10, 2018
  7. Junio C HamanoMay 10, 2018
  8. Stefan BellerMay 10, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.