config: clarify memory ownership in git_config_string()
The out parameter of `git_config_string()` is a `const char **` even though we transfer ownership of memory to the caller. This is quite misleading and has led to many memory leaks all over the place. Adapt the parameter to instead be `char **`. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
83024d98f7
commit
1b261c20ed
8
diff.c
8
diff.c
@ -56,8 +56,8 @@ static int diff_color_moved_default;
|
||||
static int diff_color_moved_ws_default;
|
||||
static int diff_context_default = 3;
|
||||
static int diff_interhunk_context_default;
|
||||
static const char *diff_word_regex_cfg;
|
||||
static const char *external_diff_cmd_cfg;
|
||||
static char *diff_word_regex_cfg;
|
||||
static char *external_diff_cmd_cfg;
|
||||
static char *diff_order_file_cfg;
|
||||
int diff_auto_refresh_index = 1;
|
||||
static int diff_mnemonic_prefix;
|
||||
@ -412,11 +412,11 @@ int git_diff_ui_config(const char *var, const char *value,
|
||||
}
|
||||
if (!strcmp(var, "diff.srcprefix")) {
|
||||
FREE_AND_NULL(diff_src_prefix);
|
||||
return git_config_string((const char **) &diff_src_prefix, var, value);
|
||||
return git_config_string(&diff_src_prefix, var, value);
|
||||
}
|
||||
if (!strcmp(var, "diff.dstprefix")) {
|
||||
FREE_AND_NULL(diff_dst_prefix);
|
||||
return git_config_string((const char **) &diff_dst_prefix, var, value);
|
||||
return git_config_string(&diff_dst_prefix, var, value);
|
||||
}
|
||||
if (!strcmp(var, "diff.relative")) {
|
||||
diff_relative = git_config_bool(var, value);
|
||||
|
Reference in New Issue
Block a user