Browse Source

added memory debugging code

fixed memory leak in free_list()

free memory associated with global settings on exit
0.9
Michael Elkins 23 years ago
parent
commit
f0c7fdf008
  1. 3
      Makefile.am
  2. 2
      TODO
  3. 17
      config.c
  4. 8
      configure.in
  5. 2
      isync.h
  6. 2
      list.c
  7. 6
      main.c

3
Makefile.am

@ -1,5 +1,8 @@
bin_PROGRAMS=isync
isync_SOURCES=main.c imap.c sync.c maildir.c isync.h list.c cram.c config.c
isync_LDADD=@DEBUGOBJ@
isync_DEPENDENCIES=@DEBUGOBJ@
EXTRA_isync_SOURCES=debug.c
man_MANS=isync.1
EXTRA_DIST=sample.isyncrc $(man_MANS)
INCLUDES=$(RPM_OPT_FLAGS)

2
TODO

@ -1,7 +1,5 @@
add support for syncing with other: and shared: via NAMESPACE
finish implementing --quiet
--fast downloads the last message again if no new messages have arrived
isync gets confused when new mail is delivered while in the middle of an

17
config.c

@ -18,8 +18,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define _GNU_SOURCE 1
#include <unistd.h>
#include <limits.h>
#include <errno.h>
@ -39,16 +37,14 @@ config_defaults (config_t * conf)
memcpy (conf, &global, sizeof (config_t));
}
#ifndef HAVE_STRNDUP
static char *
strndup (const char *s, size_t nchars)
my_strndup (const char *s, size_t nchars)
{
char *r = malloc (sizeof (char) * (nchars + 1));
strncpy (r, s, nchars);
r[nchars] = 0;
return r;
}
#endif /* ! HAVE_STRNDUP */
char *
expand_strdup (const char *s)
@ -73,7 +69,7 @@ expand_strdup (const char *s)
p = strchr (s, '/');
if (p)
{
user = strndup (s, (int)(p - s));
user = my_strndup (s, (int)(p - s));
p++;
}
else
@ -324,3 +320,12 @@ find_box (const char *s)
}
return 0;
}
void
free_config (void)
{
free (global.user);
free (global.maildir);
free (global.host);
free (global.pass);
}

8
configure.in

@ -8,7 +8,13 @@ AC_ARG_WITH(ssl-dir, [ --with-ssl-dir=DIR location where openssl is insalled],
else
AC_MSG_ERROR(can't find OpenSSL in $withval)
fi])
AC_CHECK_FUNCS(getopt_long strndup)
AC_ARG_ENABLE(debug, [ --enable-debug enable memory debugging
code],
[AC_DEFINE(DEBUG),
DEBUGOBJ=debug.o],
[DEBUGOBJ=''])
AC_SUBST(DEBUGOBJ)
AC_CHECK_FUNCS(getopt_long)
AC_CHECK_LIB(socket,socket)
AC_CHECK_LIB(nsl,inet_ntoa)
AC_CHECK_LIB(crypto,ERR_error_string)

2
isync.h

@ -23,6 +23,7 @@
#if HAVE_LIBSSL
#include <openssl/ssl.h>
#endif
#include "debug.h"
typedef struct
{
@ -173,6 +174,7 @@ int sync_mailbox (mailbox_t *, imap_t *, int, unsigned int, unsigned int);
void load_config (const char *);
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);

2
list.c

@ -153,7 +153,7 @@ free_list (list_t * list)
{
tmp = list;
list = list->next;
if (is_list (list))
if (is_list (tmp))
free_list (tmp->child);
else if (is_atom (tmp))
free (tmp->val);

6
main.c

@ -334,5 +334,11 @@ cleanup:
/* gracefully close connection to the IMAP server */
imap_close (imap);
free_config ();
#if DEBUG
debug_cleanup ();
#endif
exit (0);
}

Loading…
Cancel
Save