mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-28 21:54:10 +01:00
cli/config: allocate config using talloc_zero
Do not initialize each field separately. It's more robust to allocate the config with zero initialization, and only set the non-zero defaults individually.
This commit is contained in:
parent
1106412473
commit
08b6fd75ab
1 changed files with 4 additions and 16 deletions
|
@ -334,7 +334,7 @@ notmuch_config_open (void *ctx,
|
||||||
int file_had_search_group;
|
int file_had_search_group;
|
||||||
int file_had_crypto_group;
|
int file_had_crypto_group;
|
||||||
|
|
||||||
notmuch_config_t *config = talloc (ctx, notmuch_config_t);
|
notmuch_config_t *config = talloc_zero (ctx, notmuch_config_t);
|
||||||
if (config == NULL) {
|
if (config == NULL) {
|
||||||
fprintf (stderr, "Out of memory.\n");
|
fprintf (stderr, "Out of memory.\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -342,6 +342,9 @@ notmuch_config_open (void *ctx,
|
||||||
|
|
||||||
talloc_set_destructor (config, notmuch_config_destructor);
|
talloc_set_destructor (config, notmuch_config_destructor);
|
||||||
|
|
||||||
|
/* non-zero defaults */
|
||||||
|
config->maildir_synchronize_flags = TRUE;
|
||||||
|
|
||||||
if (filename) {
|
if (filename) {
|
||||||
config->filename = talloc_strdup (config, filename);
|
config->filename = talloc_strdup (config, filename);
|
||||||
} else if ((notmuch_config_env = getenv ("NOTMUCH_CONFIG"))) {
|
} else if ((notmuch_config_env = getenv ("NOTMUCH_CONFIG"))) {
|
||||||
|
@ -353,21 +356,6 @@ notmuch_config_open (void *ctx,
|
||||||
|
|
||||||
config->key_file = g_key_file_new ();
|
config->key_file = g_key_file_new ();
|
||||||
|
|
||||||
config->is_new = FALSE;
|
|
||||||
config->database_path = NULL;
|
|
||||||
config->user_name = NULL;
|
|
||||||
config->user_primary_email = NULL;
|
|
||||||
config->user_other_email = NULL;
|
|
||||||
config->user_other_email_length = 0;
|
|
||||||
config->new_tags = NULL;
|
|
||||||
config->new_tags_length = 0;
|
|
||||||
config->new_ignore = NULL;
|
|
||||||
config->new_ignore_length = 0;
|
|
||||||
config->maildir_synchronize_flags = TRUE;
|
|
||||||
config->search_exclude_tags = NULL;
|
|
||||||
config->search_exclude_tags_length = 0;
|
|
||||||
config->crypto_gpg_path = NULL;
|
|
||||||
|
|
||||||
if (! get_config_from_file (config, create_new)) {
|
if (! get_config_from_file (config, create_new)) {
|
||||||
talloc_free (config);
|
talloc_free (config);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in a new issue