From: Patrick Steinhardt Date: Mon, 25 Mar 2024 09:10:45 GMT Subject: Re: [PATCH 10/15] builtin/pack-refs: release allocated memory Message-ID: In-Reply-To: On Wed, Mar 20, 2024 at 04:23:54PM -0700, Karthik Nayak wrote: > Patrick Steinhardt writes: > > > Some of the command line options in `cmd_pack_refs()` require us to > > allocate memory. This memory is never released and thus leaking, but we > > paper over this leak by declaring the respective variables as `static` > > function-level variables, which is somewhat awkward. > > > > Refactor the code to release the allocated memory and drop the `static` > > declaration. While at it, remove the useless `flags` variable. > > > > Tangent: I was looking at `files_pack_refs` and it seems like there are > a bunch of `die(...)` calls there. I wonder if it would be nicer to use > `error()` instead so we could do a better job at cleanup. I agree that this would be a nice refactoring. Patrick