Re: [PATCH v2 3/3] unpack_trees_options: free messages when done
- From
- Martin Ågren <martin.agren@gmail.com>
- Date
- May 18, 2018, 05:08 UTC
- Message-ID
- <CAN0heSo80SjjGtC2x9s-TmNY0=W=YWTYxyjeuAQ3utEAEynXeA@mail.gmail.com>
- In-Reply-To
- <xmqqin7m53x0.fsf@gitster-ct.c.googlers.com>
On 18 May 2018 at 00:10, Junio C Hamano <gitster@pobox.com> wrote:
Show 5 quoted lines
> Martin Ågren <martin.agren@gmail.com> writes: > >> The `opts` string array contains multiple copies of the same pointers. >> Be careful to only free each pointer once, then zeroize the whole array >> so that we do not leave any dangling pointers.
Show 7 quoted lines
> I wonder if an approach that is longer-term a bit more maintainable > is to add a new string-list instance to opts, save these xstrfmt()'ed > messages to it when setup_unpack_trees_porcelain() create them, and > then make clear_unpack_trees_porcelain() pay *no* attention to msg[] > array and the positions of these allocated messages and duplicates > but just reclaim the resources held in that string-list, or > something like that.
Thank you for thoughts and this suggestion. I will try this out, hopefully later today.
Martin