[PATCH 1/2] cli: abstract common config get/set code
David Bremner
david at tethera.net
Wed Jan 15 05:24:53 PST 2014
Jani Nikula <jani at nikula.org> writes:
> Pretty straightforward abstraction similar to get/set list.
> ---
> notmuch-config.c | 80 ++++++++++++++++++++----------------------------------
> 1 file changed, 29 insertions(+), 51 deletions(-)
>
> diff --git a/notmuch-config.c b/notmuch-config.c
> index befe9b5..305d213 100644
> --- a/notmuch-config.c
> +++ b/notmuch-config.c
> @@ -496,6 +496,29 @@ notmuch_config_is_new (notmuch_config_t *config)
> return config->is_new;
> }
>
> +static const char *
> +_config_get (notmuch_config_t *config, char **field,
> + const char *group, const char *key)
> +{
> + if (*field == NULL) {
> + char *value;
> + value = g_key_file_get_string (config->key_file, group, key, NULL);
> + if (value) {
> + *field = talloc_strdup (config, value);
> + free (value);
> + }
> + }
> + return *field;
> +}
> +
The use of NULL here is clear enough in the context of the patch, but I
think it deserves a comment in the code; it is not obviously just code
movement after the patch is applied.
More information about the notmuch
mailing list