summaryrefslogtreecommitdiff
path: root/builtin/commit.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-05-06 10:55:56 +0200
committerJunio C Hamano <gitster@pobox.com>2024-05-06 11:50:07 -0700
commita78b462976d36304212f93b6d4a4c086a007362f (patch)
tree3cc9c03f6fa7544255fe1347a5555a4de6778709 /builtin/commit.c
parent786a3e4b8d754d2b14b1208b98eeb0a554ef19a8 (diff)
config: clarify memory ownership when preparing comment strings
The ownership of memory returned when preparing a comment string is quite intricate: when the returned value is different than the passed value, then the caller is responsible to free the memory. This is quite subtle, and it's even easier to miss because the returned value is in fact a `const char *`. Adapt the function to always return either `NULL` or a newly allocated string. The function is called at most once per git-config(1), so it's not like this micro-optimization really matters. Thus, callers are now always responsible for freeing the value. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/commit.c')
0 files changed, 0 insertions, 0 deletions