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

Re: [RFC PATCH 2/2] Replace calls to strbuf_init(&foo, 0) with static STRBUF_INIT initializer

From
Alex Riesen <raa.lkml@gmail.com>
Date
Oct 9, 2008, 21:28 UTC
Message-ID
<81b0412b0810091428o6a4ea772q6a10cd295e4fcd7d@mail.gmail.com>
In-Reply-To
<UUi8gSMV6CruoYIkVNOQZ4FNzsbqZcSNu6jdYH8GqIo@cipher.nrlssc.navy.mil>
2008/10/9 Brandon Casey <casey@nrlssc.navy.mil>:
Show 11 quoted lines
> Many call sites use strbuf_init(&foo, 0) to initialize local strbuf variable
> "foo" which has not been accessed since its declaration. These can be
> replaced with a static initialization using the STRBUF_INIT macro which is
> just as readable, saves a function call, and takes up fewer lines.
>
> Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
> ---
>
>
> This does the same thing for strbuf_init() that the last one did for memset().
>

But it does this using a predefined interface (using the STRBUG_INIT macro), so next time strbuf changed, the code using it may be left as is.

I didn't like the memset->zero-init, but I do like this one. It is a bit unclear, by the way, why strbuf_init wasn't inlined.

Previous: Brandon Casey
Message 2 of 2 in “Replace calls to strbuf_init(&foo, 0) with static STRBUF_INIT initializer”
  1. 2/2 Replace calls to strbuf_init(&foo, 0) with static STRBUF_INIT initializerBrandon Casey, Oct 9, 2008
  2. Alex RiesenOct 9, 2008

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.