Re: [PATCH v3 2/2] setup: fix memory leaks with `struct repository_format`

2019-02-26 Thread Jeff King
On Mon, Feb 25, 2019 at 08:21:07PM +0100, Martin Ågren wrote: > It's time to resurrect this thread. I've reworked this patch to avoid > the compound literal when re-initing a struct, and I've been going back > and forth on this point about having to initialize to `..._INIT` or risk > crashing. And

Re: [PATCH v3 2/2] setup: fix memory leaks with `struct repository_format`

2019-02-25 Thread Martin Ågren
On Fri, 25 Jan 2019 at 20:51, Jeff King wrote: > > > On Wed, 23 Jan 2019 at 06:57, Jeff King wrote: > > > > > > On Tue, Jan 22, 2019 at 10:45:48PM +0100, Martin Ågren wrote: > > > > > > > Call `clear_...()` at the start of `read_...()` instead of just zeroing > > > > the struct, since we sometime

Re: [PATCH v3 2/2] setup: fix memory leaks with `struct repository_format`

2019-01-25 Thread Jeff King
On Fri, Jan 25, 2019 at 08:24:35PM +0100, Martin Ågren wrote: > On Wed, 23 Jan 2019 at 06:57, Jeff King wrote: > > > > On Tue, Jan 22, 2019 at 10:45:48PM +0100, Martin Ågren wrote: > > > > > Call `clear_...()` at the start of `read_...()` instead of just zeroing > > > the struct, since we sometim

Re: [PATCH v3 2/2] setup: fix memory leaks with `struct repository_format`

2019-01-25 Thread Martin Ågren
On Thu, 24 Jan 2019 at 01:15, brian m. carlson wrote: > > On Wed, Jan 23, 2019 at 12:57:05AM -0500, Jeff King wrote: > > > +void clear_repository_format(struct repository_format *format) > > > +{ > > > + string_list_clear(&format->unknown_extensions, 0); > > > + free(format->work_tree); > > >

Re: [PATCH v3 2/2] setup: fix memory leaks with `struct repository_format`

2019-01-25 Thread Martin Ågren
On Wed, 23 Jan 2019 at 06:57, Jeff King wrote: > > On Tue, Jan 22, 2019 at 10:45:48PM +0100, Martin Ågren wrote: > > > Call `clear_...()` at the start of `read_...()` instead of just zeroing > > the struct, since we sometimes enter the function multiple times. This > > means that it is important t

Re: [PATCH v3 2/2] setup: fix memory leaks with `struct repository_format`

2019-01-23 Thread brian m. carlson
On Wed, Jan 23, 2019 at 12:57:05AM -0500, Jeff King wrote: > This uses designated initializers, which is a C99-ism, but one we've > used previously and feel confident in. But... > > > +void clear_repository_format(struct repository_format *format) > > +{ > > + string_list_clear(&format->unknown_

Re: [PATCH v3 2/2] setup: fix memory leaks with `struct repository_format`

2019-01-22 Thread Jeff King
On Tue, Jan 22, 2019 at 10:45:48PM +0100, Martin Ågren wrote: > Call `clear_...()` at the start of `read_...()` instead of just zeroing > the struct, since we sometimes enter the function multiple times. This > means that it is important to initialize the struct before calling > `read_...()`, so d