diff options
author | Stig Bjørlykke <stig@bjorlykke.org> | 2008-01-15 21:41:52 +0000 |
---|---|---|
committer | Stig Bjørlykke <stig@bjorlykke.org> | 2008-01-15 21:41:52 +0000 |
commit | 3993d555fb090d50ecd84e6452c7973c3d923e55 (patch) | |
tree | a9ae2c65e914f80d9d2ff09f2f5b39e408d87025 /disabled_protos.c | |
parent | cd93b15841d302e222f17cf68d9c6ac06ac60075 (diff) |
Discard existing list of disabled protocols in read_disabled_protos_list()
even if disabled_protos file does not exist. This fixes a problem with
disabled protocols when changing profile.
svn path=/trunk/; revision=24102
Diffstat (limited to 'disabled_protos.c')
-rw-r--r-- | disabled_protos.c | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/disabled_protos.c b/disabled_protos.c index 7fd7775b5a..bd1679ff26 100644 --- a/disabled_protos.c +++ b/disabled_protos.c @@ -54,6 +54,25 @@ static GList *disabled_protos = NULL; #define INIT_BUF_SIZE 128 +static void +discard_existing_list (GList **flp) +{ + GList *fl_ent; + protocol_def *prot; + + if (*flp != NULL) { + fl_ent = g_list_first(*flp); + while (fl_ent != NULL) { + prot = (protocol_def *) fl_ent->data; + g_free(prot->name); + g_free(prot); + fl_ent = fl_ent->next; + } + g_list_free(*flp); + *flp = NULL; + } +} + /* * Read in a list of disabled protocols. * @@ -80,6 +99,9 @@ read_disabled_protos_list(char **gpath_return, int *gopen_errno_return, /* Construct the pathname of the global disabled protocols file. */ gff_path = get_datafile_path(GLOBAL_PROTOCOLS_FILE_NAME); + /* If we already have a list of protocols, discard it. */ + discard_existing_list (&global_disabled_protos); + /* Read the global disabled protocols file, if it exists. */ *gpath_return = NULL; if ((ff = eth_fopen(gff_path, "r")) != NULL) { @@ -110,6 +132,9 @@ read_disabled_protos_list(char **gpath_return, int *gopen_errno_return, /* Construct the pathname of the user's disabled protocols file. */ ff_path = get_persconffile_path(PROTOCOLS_FILE_NAME, TRUE, FALSE); + /* If we already have a list of protocols, discard it. */ + discard_existing_list (&disabled_protos); + /* Read the user's disabled protocols file, if it exists. */ *path_return = NULL; if ((ff = eth_fopen(ff_path, "r")) != NULL) { @@ -141,7 +166,6 @@ static int read_disabled_protos_list_file(const char *ff_path, FILE *ff, GList **flp) { - GList *fl_ent; protocol_def *prot; int c; char *prot_name; @@ -149,18 +173,6 @@ read_disabled_protos_list_file(const char *ff_path, FILE *ff, int prot_name_index; int line = 1; - /* If we already have a list of protocols, discard it. */ - if (*flp != NULL) { - fl_ent = g_list_first(*flp); - while (fl_ent != NULL) { - prot = (protocol_def *) fl_ent->data; - g_free(prot->name); - g_free(prot); - fl_ent = fl_ent->next; - } - g_list_free(*flp); - *flp = NULL; - } /* Allocate the protocol name buffer. */ prot_name_len = INIT_BUF_SIZE; |