From: James Liu Date: Wed, 07 Aug 2024 08:31:33 GMT Subject: Re: [PATCH 13/22] builtin/fast-export: plug leaking tag names Message-ID: In-Reply-To: <64366155dee25209ab9c434016c5918d47d7e1d5.1722933642.git.ps@pks.im> On Tue Aug 6, 2024 at 7:00 PM AEST, Patrick Steinhardt wrote: > Refactor the code to make the lists we put those names into duplicate > the memory. This allows us to properly free the string as required and > thus plugs the memory leak. > > While this requires us to allocate more data overall, it shouldn't be > all that bad given that the number of allocations corresponds with the > number of command line parameters, which typically aren't all that many. Ahh so using the `STRING_LIST_INIT_DUP` initialiser means that every time we call `string_list_append()` on the list, we retain ownership of the string and the list gets its own copy. That means we're able to free our own copy later on.