mbox series

[0/3] diff: build parseopts array on demand

Message ID 0620b4a6-b80a-d8a0-5a35-857b9fe0c986@web.de (mailing list archive)
Headers show
Series diff: build parseopts array on demand | expand

Message

René Scharfe Nov. 30, 2022, 6:01 p.m. UTC
Calling repo_init_revisions() and release_revisions() in that order
leaks the memory allocated for the parseopts array in the embedded
struct diff_options member.  Get rid of that leak by reducing the
lifetime of that array.

Original patch:
https://lore.kernel.org/git/4fd82dc6-e0f8-0638-5b10-16bfef39a171@web.de/

Submitted separately from that thread because it's independent enough.

  diff: factor out add_diff_options()
  diff: let prep_parse_options() return parseopt array
  diff: remove parseopts member of struct diff_options

 builtin/range-diff.c |  2 +-
 diff-no-index.c      |  3 +--
 diff.c               | 26 +++++++++++++++-----------
 diff.h               |  1 +
 4 files changed, 18 insertions(+), 14 deletions(-)

--
2.38.1

Comments

Junio C Hamano Dec. 1, 2022, 1:02 a.m. UTC | #1
René Scharfe <l.s.r@web.de> writes:

> Calling repo_init_revisions() and release_revisions() in that order
> leaks the memory allocated for the parseopts array in the embedded
> struct diff_options member.  Get rid of that leak by reducing the
> lifetime of that array.

Makes sense.