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

Re: [PATCH] revision: replace "struct cmdline_pathspec" with argv_array

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 21, 2017, 04:11 UTC
Message-ID
<xmqqingclmh3.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20170920203659.xqy76bg5nfabvbfx@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 20 quoted lines
> Subject: [PATCH] revision: replace "struct cmdline_pathspec" with argv_array
>
> We assemble an array of strings in a custom struct,
> NULL-terminate the result, and then pass it to
> parse_pathspec().
>
> But then we never free the array or the individual strings
> (nor can we do the latter, as they are heap-allocated when
> they come from stdin but not when they come from the
> passed-in argv).
>
> Let's swap this out for an argv_array. It does the same
> thing with fewer lines of code, and it's safe to call
> argv_array_clear() at the end to avoid a memory leak.
>
> Reported-by: Martin Ågren <martin.agren@gmail.com>
> Signed-off-by: Jeff King <peff@peff.net>
> ---
>  revision.c | 39 +++++++++++----------------------------
>  1 file changed, 11 insertions(+), 28 deletions(-)
Makes sense.  Thanks for cleaning up the mess I made.
Previous: Martin Ågren
Message 12 of 12 in “revision: fix memory leaks with `struct cmdline_pathspec`”
  1. revision: fix memory leaks with `struct cmdline_pathspec`Martin Ågren, Sep 20, 2017
  2. Jeff KingSep 20, 2017
  3. revision: replace "struct cmdline_pathspec" with argv_arrayJeff King, Sep 20, 2017
  4. Jonathan NiederSep 20, 2017
  5. Jeff KingSep 21, 2017
  6. Jonathan NiederSep 21, 2017
  7. Jeff KingSep 21, 2017
  8. Jonathan NiederSep 21, 2017
  9. Jeff KingSep 21, 2017
  10. Junio C HamanoSep 21, 2017
  11. Martin ÅgrenSep 21, 2017
  12. Junio C HamanoSep 21, 2017

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.