From: Timo Sirainen Date: Thu, 10 Apr 2003 22:37:25 +0000 (+0300) Subject: minor memory leak/cleanup fixes X-Git-Tag: 1.1.alpha1~4755 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=18d788657cff0fc3905b6a484d33c8c9fc2b9eba;p=thirdparty%2Fdovecot%2Fcore.git minor memory leak/cleanup fixes --HG-- branch : HEAD --- diff --git a/src/imap/main.c b/src/imap/main.c index f2a7c03183..68b6dbb216 100644 --- a/src/imap/main.c +++ b/src/imap/main.c @@ -143,6 +143,7 @@ static void main_deinit(void) i_warning("Killed with signal %d", lib_signal_kill); clients_deinit(); + mail_storage_deinit(); closelog(); } diff --git a/src/lib-storage/mail-storage.c b/src/lib-storage/mail-storage.c index 87f261e016..25da04fa10 100644 --- a/src/lib-storage/mail-storage.c +++ b/src/lib-storage/mail-storage.c @@ -59,6 +59,18 @@ void mail_storage_init(void) } } +void mail_storage_deinit(void) +{ + struct mail_storage_list *next; + + while (storages != NULL) { + next = storages->next; + + i_free(storages); + storages = next; + } +} + void mail_storage_class_register(struct mail_storage *storage_class) { struct mail_storage_list *list, **pos; @@ -160,8 +172,7 @@ void mail_storage_destroy(struct mail_storage *storage) { i_assert(storage != NULL); - i_free(storage->dir); - i_free(storage); + storage->free(storage); } void mail_storage_clear_error(struct mail_storage *storage) @@ -212,6 +223,7 @@ void mail_storage_set_internal_error(struct mail_storage *storage) tm = localtime(&ioloop_time); + i_free(storage->error); storage->error = strftime(str, sizeof(str), CRITICAL_MSG, tm) > 0 ? i_strdup(str) : i_strdup("Internal error"); storage->syntax_error = FALSE; diff --git a/src/lib-storage/mail-storage.h b/src/lib-storage/mail-storage.h index 93e8c92d72..e82596e2a7 100644 --- a/src/lib-storage/mail-storage.h +++ b/src/lib-storage/mail-storage.h @@ -428,8 +428,8 @@ struct mail_storage_callbacks { extern enum client_workarounds client_workarounds; extern int full_filesystem_access; -/* Initialize mail storage. */ void mail_storage_init(void); +void mail_storage_deinit(void); /* register all mail storages */ void mail_storage_register_all(void); diff --git a/src/lib/ioloop.c b/src/lib/ioloop.c index e8a10cbd88..f17c875e69 100644 --- a/src/lib/ioloop.c +++ b/src/lib/ioloop.c @@ -334,6 +334,8 @@ struct ioloop *io_loop_create(pool_t pool) void io_loop_destroy(struct ioloop *ioloop) { + pool_t pool; + while (ioloop->ios != NULL) { struct io *io = ioloop->ios; @@ -361,5 +363,7 @@ void io_loop_destroy(struct ioloop *ioloop) i_assert(ioloop == current_ioloop); current_ioloop = current_ioloop->prev; - pool_unref(ioloop->pool); + pool = ioloop->pool; + p_free(pool, ioloop); + pool_unref(pool); } diff --git a/src/pop3/main.c b/src/pop3/main.c index 3bd92ae7de..33123c11a2 100644 --- a/src/pop3/main.c +++ b/src/pop3/main.c @@ -110,6 +110,7 @@ static void main_deinit(void) i_warning("Killed with signal %d", lib_signal_kill); clients_deinit(); + mail_storage_deinit(); closelog(); }