diff --git a/src/config.c b/src/config.c index c91acfd..8ae9366 100644 --- a/src/config.c +++ b/src/config.c @@ -172,7 +172,6 @@ load_config (const char *where, int *o2o) if (boxes) goto forbid; /* this only affects the global setting */ - free (global.maildir); global.maildir = expand_strdup (val); } else if (!strcasecmp ("folder", cmd)) @@ -204,14 +203,7 @@ load_config (const char *where, int *o2o) cfg->host = strdup (val); } else if (!strcasecmp ("user", cmd)) - { - if (boxes) - cfg->user = strdup (val); - else { - free (global.user); - global.user = strdup (val); - } - } + cfg->user = strdup (val); else if (!strcasecmp ("pass", cmd)) cfg->pass = strdup (val); else if (!strcasecmp ("port", cmd)) @@ -288,12 +280,3 @@ find_box (const char *s) } return 0; } - -void -free_config (void) -{ - free (global.user); - free (global.maildir); - free (global.host); - free (global.pass); -} diff --git a/src/isync.h b/src/isync.h index 88a868f..bc40ae8 100644 --- a/src/isync.h +++ b/src/isync.h @@ -196,7 +196,6 @@ int sync_mailbox (mailbox_t *, imap_t *, int, unsigned int, unsigned int); void load_config (const char *, int *); char * expand_strdup (const char *s); config_t *find_box (const char *); -void free_config (void); void imap_close (imap_t *); int imap_copy_message (imap_t * imap, unsigned int uid, const char *mailbox); diff --git a/src/main.c b/src/main.c index 3b16ceb..3cfbd59 100644 --- a/src/main.c +++ b/src/main.c @@ -35,10 +35,6 @@ #include #include "isync.h" -#if HAVE_GETOPT_LONG -#define _GNU_SOURCE -#include - int Quiet; void @@ -61,6 +57,9 @@ infoc (char c) putchar (c); } +#if HAVE_GETOPT_LONG +# define _GNU_SOURCE +# include struct option Opts[] = { {"all", 0, NULL, 'a'}, {"list", 0, NULL, 'l'}, @@ -183,7 +182,7 @@ int main (int argc, char **argv) { int i; - int ret = 1; + int ret; config_t *box = 0; mailbox_t *mail = 0; imap_t *imap = 0; @@ -274,8 +273,7 @@ main (int argc, char **argv) global.folder = optarg; break; case 'M': - free (global.maildir); - global.maildir = strdup (optarg); + global.maildir = optarg; break; case 'I': global.inbox = optarg; @@ -291,7 +289,6 @@ main (int argc, char **argv) global.host = optarg; break; case 'u': - free (global.user); global.user = optarg; break; case 'V': @@ -348,9 +345,9 @@ main (int argc, char **argv) imap = imap_connect (&global); if (!imap) - goto bork; + return 1; if (imap_list (imap)) - goto bork; + return 1; } if (list) { @@ -462,12 +459,7 @@ main (int argc, char **argv) if (all) box = box->next; } - /* gracefully close connection to the IMAP server */ imap_close (imap); - - bork: - free_config (); - return ret; }