isync

mailbox synchronization program
git clone https://git.code.sf.net/p/isync/isync
Log | Files | Refs | README | LICENSE

commit 28e240a36b838eeab1e310f42e5b5b964acbebeb
parent d2b39d2c8906bfec2669835de45af773099bc372
Author: Oswald Buddenhagen <ossi@users.sf.net>
Date:   Mon,  5 May 2003 17:58:28 +0000

don't free any config strings - who cares for a few bytes?
this fixes some crashes at exit.

Diffstat:
Msrc/config.c | 19+------------------
Msrc/isync.h | 1-
Msrc/main.c | 22+++++++---------------
3 files changed, 8 insertions(+), 34 deletions(-)

diff --git 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 @@ -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 @@ -35,10 +35,6 @@ #include <dirent.h> #include "isync.h" -#if HAVE_GETOPT_LONG -#define _GNU_SOURCE -#include <getopt.h> - int Quiet; void @@ -61,6 +57,9 @@ infoc (char c) putchar (c); } +#if HAVE_GETOPT_LONG +# define _GNU_SOURCE +# include <getopt.h> 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; }