dovecot: Let deinit() free all the memory itself after all.
dovecot at dovecot.org
dovecot at dovecot.org
Sat Sep 22 19:40:51 EEST 2007
details: http://hg.dovecot.org/dovecot/rev/af14dc005392
changeset: 6476:af14dc005392
user: Timo Sirainen <tss at iki.fi>
date: Sat Sep 22 19:19:13 2007 +0300
description:
Let deinit() free all the memory itself after all.
diffstat:
4 files changed, 14 insertions(+), 7 deletions(-)
src/lib-sql/driver-mysql.c | 9 ++++++---
src/lib-sql/driver-pgsql.c | 2 ++
src/lib-sql/driver-sqlite.c | 8 ++++++--
src/lib-sql/sql-api.c | 2 --
diffs (85 lines):
diff -r ee420f238104 -r af14dc005392 src/lib-sql/driver-mysql.c
--- a/src/lib-sql/driver-mysql.c Sat Sep 22 19:03:33 2007 +0300
+++ b/src/lib-sql/driver-mysql.c Sat Sep 22 19:19:13 2007 +0300
@@ -245,9 +245,11 @@ static struct sql_db *driver_mysql_init_
static struct sql_db *driver_mysql_init_v(const char *connect_string)
{
struct mysql_db *db;
-
- db = i_new(struct mysql_db, 1);
- db->pool = pool_alloconly_create("mysql driver", 512);;
+ pool_t pool;
+
+ pool = pool_alloconly_create("mysql driver", 512);
+ db = p_new(pool, struct mysql_db, 1);
+ db->pool = pool;
db->api = driver_mysql_db;
p_array_init(&db->connections, db->pool, 6);
@@ -265,6 +267,7 @@ static void driver_mysql_deinit_v(struct
for (i = 0; i < count; i++)
(void)driver_mysql_connection_free(&conn[i]);
+ array_free(&_db->module_contexts);
pool_unref(&db->pool);
}
diff -r ee420f238104 -r af14dc005392 src/lib-sql/driver-pgsql.c
--- a/src/lib-sql/driver-pgsql.c Sat Sep 22 19:03:33 2007 +0300
+++ b/src/lib-sql/driver-pgsql.c Sat Sep 22 19:19:13 2007 +0300
@@ -213,6 +213,8 @@ static void driver_pgsql_deinit_v(struct
driver_pgsql_close(db);
i_free(db->error);
i_free(db->connect_string);
+ array_free(&_db->module_contexts);
+ i_free(db);
}
static enum sql_db_flags
diff -r ee420f238104 -r af14dc005392 src/lib-sql/driver-sqlite.c
--- a/src/lib-sql/driver-sqlite.c Sat Sep 22 19:03:33 2007 +0300
+++ b/src/lib-sql/driver-sqlite.c Sat Sep 22 19:19:13 2007 +0300
@@ -1,6 +1,7 @@
/* Copyright (C) 2006 Jakob Hirsch */
#include "lib.h"
+#include "array.h"
#include "str.h"
#include "sql-api-private.h"
@@ -60,11 +61,13 @@ static struct sql_db *driver_sqlite_init
static struct sql_db *driver_sqlite_init_v(const char *connect_string)
{
struct sqlite_db *db;
+ pool_t pool;
i_assert(connect_string != NULL);
- db = i_new(struct sqlite_db, 1);
- db->pool = pool_alloconly_create("sqlite driver", 512);;
+ pool = pool_alloconly_create("sqlite driver", 512);
+ db = p_new(pool, struct sqlite_db, 1);
+ db->pool = pool;
db->api = driver_sqlite_db;
db->dbfile = p_strdup(db->pool, connect_string);
db->connected = FALSE;
@@ -77,6 +80,7 @@ static void driver_sqlite_deinit_v(struc
struct sqlite_db *db = (struct sqlite_db *)_db;
sqlite3_close(db->sqlite);
+ array_free(&_db->module_contexts);
pool_unref(&db->pool);
}
diff -r ee420f238104 -r af14dc005392 src/lib-sql/sql-api.c
--- a/src/lib-sql/sql-api.c Sat Sep 22 19:03:33 2007 +0300
+++ b/src/lib-sql/sql-api.c Sat Sep 22 19:19:13 2007 +0300
@@ -62,8 +62,6 @@ void sql_deinit(struct sql_db **_db)
*_db = NULL;
db->v.deinit(db);
- array_free(&db->module_contexts);
- i_free(db);
}
enum sql_db_flags sql_get_flags(struct sql_db *db)
More information about the dovecot-cvs
mailing list