]> git.ipfire.org Git - thirdparty/git.git/commit
diff: refactor code to clarify memory ownership of prefixes
authorPatrick Steinhardt <ps@pks.im>
Mon, 27 May 2024 11:46:20 +0000 (13:46 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 May 2024 18:19:59 +0000 (11:19 -0700)
commitf9c19896749912da7add7ef855ea0543cca91bef
treead2f5d42af38b699b68d795a91f856176c718f9d
parent6073b3b5c37716c50244d635e7c358f41f43e286
diff: refactor code to clarify memory ownership of prefixes

The source and destination prefixes are tracked in a `const char *`
array, but may at times contain allocated strings. The result is that
those strings may be leaking because we never free them.

Refactor the code to always store allocated strings in those variables,
freeing them as required. This requires us to handle the default values
a bit different compared to before. But given that there is only a
single callsite where we use the variables to `struct diff_options` it's
easy to handle the defaults there.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c