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

Use more strbufs series [on top of next]

From
Pierre Habouzit <madcoder@debian.org>
Date
Sep 9, 2007, 00:04 UTC
Message-ID
<11892962763548-git-send-email-madcoder@debian.org>
  Here is a series of patches on top of next, which use strbufs in even
more places. Most notably, it uses it in the commit pretty printer (and
commit message formatter), and it supersedes definitely read_fd
(previously in sha1_file.c).
  The latter is not strictly speaking necessary, but strbuf_read and
read_fd do almost the same. The sole difference is that read_fd use
custom reallocation mechanisms (which is bad now that strbufs exists)
though had a different semantics when an error occurs. Though, like for
strbuf_read, read_fd callers either die() or discard the buffer, and
current strbuf_read semantics works with that.
  As a result we once again have a nice reduction of the code lines.
  $ git diff --shortstat origin/next strbuf.*
   2 files changed, 24 insertions(+), 0 deletions(-)
  $ git diff --shortstat origin/next ^strbuf.*
   16 files changed, 270 insertions(+), 466 deletions(-)
  I feel that with the current series commit.c can be simplified
further, but the patch was big enough as is already.
  If this series will be rewritten for this or this reason, please note
that I found a memory leak (not a severe one though) in
builtin-archive.c, where the "fmt" pointer is allocated and never freed.
Cheers,
Next: Pierre Habouzit
Message 1 of 9 in “Use more strbufs series [on top of next]”
  1. Pierre HabouzitSep 9, 2007
  2. 1/6 Add strbuf_rtrim and strbuf_insert.Pierre Habouzit, Sep 9, 2007
  3. 2/6 Change semantics of interpolate to work like snprintf.Pierre Habouzit, Sep 9, 2007
  4. 3/6 Rework pretty_print_commit to use strbufs instead of custom buffers.Pierre Habouzit, Sep 9, 2007
  5. 4/6 Use strbuf_read in builtin-fetch-tool.c.Pierre Habouzit, Sep 9, 2007
  6. 5/6 Use strbufs to in read_message (imap-send.c), custom buffer--.Pierre Habouzit, Sep 9, 2007
  7. 6/6 Replace all read_fd use with strbuf_read, and get rid of it.Pierre Habouzit, Sep 9, 2007
  8. Pierre HabouzitSep 9, 2007
  9. Linus TorvaldsSep 27, 2007

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.