[evolution-data-server/wip/offline-cache] Fix some EBookCache, and its tests, memory leaks
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/wip/offline-cache] Fix some EBookCache, and its tests, memory leaks
- Date: Tue, 21 Mar 2017 17:31:58 +0000 (UTC)
commit 3a922254769a49a2c498fe46cf1016ba3aeb3e15
Author: Milan Crha <mcrha redhat com>
Date: Fri Feb 3 10:13:23 2017 +0100
Fix some EBookCache, and its tests, memory leaks
src/addressbook/libedata-book/e-book-cache.c | 6 +++++-
tests/libedata-book/test-cache-create-cursor.c | 8 ++++----
tests/libedata-book/test-cache-cursor-set-sexp.c | 4 ++++
tests/libedata-book/test-cache-offline.c | 6 +++---
tests/libedata-book/test-cache-utils.c | 2 ++
tests/libedata-book/test-sqlite-create-cursor.c | 8 ++++----
6 files changed, 22 insertions(+), 12 deletions(-)
---
diff --git a/src/addressbook/libedata-book/e-book-cache.c b/src/addressbook/libedata-book/e-book-cache.c
index 37b08e1..778bdfd 100644
--- a/src/addressbook/libedata-book/e-book-cache.c
+++ b/src/addressbook/libedata-book/e-book-cache.c
@@ -5939,7 +5939,11 @@ e_book_cache_finalize (GObject *object)
g_free (book_cache->priv->locale);
g_free (book_cache->priv->region_code);
- g_free (book_cache->priv->summary_fields);
+
+ if (book_cache->priv->summary_fields) {
+ summary_fields_array_free (book_cache->priv->summary_fields,
book_cache->priv->n_summary_fields);
+ book_cache->priv->summary_fields = NULL;
+ }
/* Chain up to parent's method. */
G_OBJECT_CLASS (e_book_cache_parent_class)->finalize (object);
diff --git a/tests/libedata-book/test-cache-create-cursor.c b/tests/libedata-book/test-cache-create-cursor.c
index 9ef9d15..5f75771 100644
--- a/tests/libedata-book/test-cache-create-cursor.c
+++ b/tests/libedata-book/test-cache-create-cursor.c
@@ -77,8 +77,8 @@ test_create_cursor_invalid_sort (TCUFixture *fixture,
sort_fields, sort_types, 1, &error);
g_assert (cursor == NULL);
- g_assert (error);
- g_assert (g_error_matches (error, E_CACHE_ERROR, E_CACHE_ERROR_INVALID_QUERY));
+ g_assert_error (error, E_CACHE_ERROR, E_CACHE_ERROR_INVALID_QUERY);
+ g_clear_error (&error);
}
static void
@@ -91,8 +91,8 @@ test_create_cursor_missing_sort (TCUFixture *fixture,
cursor = e_book_cache_cursor_new (fixture->book_cache, NULL, NULL, NULL, 0, &error);
g_assert (cursor == NULL);
- g_assert (error);
- g_assert (g_error_matches (error, E_CACHE_ERROR, E_CACHE_ERROR_INVALID_QUERY));
+ g_assert_error (error, E_CACHE_ERROR, E_CACHE_ERROR_INVALID_QUERY);
+ g_clear_error (&error);
}
gint
diff --git a/tests/libedata-book/test-cache-cursor-set-sexp.c
b/tests/libedata-book/test-cache-cursor-set-sexp.c
index 2cbf415..e717264 100644
--- a/tests/libedata-book/test-cache-cursor-set-sexp.c
+++ b/tests/libedata-book/test-cache-cursor-set-sexp.c
@@ -74,6 +74,8 @@ test_cursor_sexp_calculate_position (TCUCursorFixture *fixture,
/* 'blackbird' is now at position 8 out of 13, with a filtered set of contacts in en_US locale */
g_assert_cmpint (position, ==, 8);
g_assert_cmpint (total, ==, 13);
+
+ g_free (sexp);
}
static void
@@ -125,6 +127,8 @@ test_cursor_sexp_and_step (TCUCursorFixture *fixture,
data = node->data;
g_assert_cmpstr (data->uid, ==, "sorted-12");
g_slist_free_full (results, e_book_cache_search_data_free);
+
+ g_free (sexp);
}
gint
diff --git a/tests/libedata-book/test-cache-offline.c b/tests/libedata-book/test-cache-offline.c
index f3fff61..9bce4d8 100644
--- a/tests/libedata-book/test-cache-offline.c
+++ b/tests/libedata-book/test-cache-offline.c
@@ -560,13 +560,11 @@ test_offline_basics (TCUFixture *fixture,
g_assert (!e_cache_set_offline_state (E_CACHE (fixture->book_cache), uid,
E_OFFLINE_STATE_LOCALLY_MODIFIED, NULL, &error));
g_assert_error (error, E_CACHE_ERROR, E_CACHE_ERROR_NOT_FOUND);
+ g_clear_error (&error);
test_verify_storage (fixture, uid, NULL, NULL, E_OFFLINE_STATE_UNKNOWN);
test_check_offline_changes (fixture, NULL);
- g_clear_object (&contact);
- g_clear_error (&error);
-
g_assert_cmpint (e_cache_count (E_CACHE (fixture->book_cache), FALSE, NULL, &error), ==, 2);
g_assert_cmpint (e_cache_count (E_CACHE (fixture->book_cache), TRUE, NULL, &error), ==, 2);
g_assert_no_error (error);
@@ -580,6 +578,8 @@ test_offline_basics (TCUFixture *fixture,
g_assert_null (saved_extra);
g_clear_error (&error);
+ g_clear_object (&contact);
+
/* Search after delete */
test_basic_search (fixture, EXPECT_DEFAULT);
}
diff --git a/tests/libedata-book/test-cache-utils.c b/tests/libedata-book/test-cache-utils.c
index caedd46..dbcd31a 100644
--- a/tests/libedata-book/test-cache-utils.c
+++ b/tests/libedata-book/test-cache-utils.c
@@ -426,6 +426,8 @@ step_test_free (TCUStepData *data)
g_slice_free (TCUStepAssertion, assertion);
}
+ g_list_free (data->assertions);
+
g_slice_free (TCUStepData, data);
}
diff --git a/tests/libedata-book/test-sqlite-create-cursor.c b/tests/libedata-book/test-sqlite-create-cursor.c
index 0357d47..8ad9012 100644
--- a/tests/libedata-book/test-sqlite-create-cursor.c
+++ b/tests/libedata-book/test-sqlite-create-cursor.c
@@ -77,8 +77,8 @@ test_create_cursor_invalid_sort (EbSqlFixture *fixture,
sort_fields, sort_types, 1, &error);
g_assert (cursor == NULL);
- g_assert (error);
- g_assert (g_error_matches (error, E_BOOK_SQLITE_ERROR, E_BOOK_SQLITE_ERROR_INVALID_QUERY));
+ g_assert_error (error, E_BOOK_SQLITE_ERROR, E_BOOK_SQLITE_ERROR_INVALID_QUERY);
+ g_clear_error (&error);
}
static void
@@ -91,8 +91,8 @@ test_create_cursor_missing_sort (EbSqlFixture *fixture,
cursor = e_book_sqlite_cursor_new (fixture->ebsql, NULL, NULL, NULL, 0, &error);
g_assert (cursor == NULL);
- g_assert (error);
- g_assert (g_error_matches (error, E_BOOK_SQLITE_ERROR, E_BOOK_SQLITE_ERROR_INVALID_QUERY));
+ g_assert_error (error, E_BOOK_SQLITE_ERROR, E_BOOK_SQLITE_ERROR_INVALID_QUERY);
+ g_clear_error (&error);
}
gint
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]