[evolution-data-server] Take advantage of add-contact util function in test-changes and don't return newly-allocated memory



commit 96e9dd05a9ffd87cdaf8071d524a7c53892d2165
Author: Travis Reitter <treitter gmail com>
Date:   Tue Dec 29 12:36:28 2009 -0800

    Take advantage of add-contact util function in test-changes and don't return newly-allocated memory when the caller may not care about the return value.

 addressbook/tests/ebook/ebook-test-utils.c       |    4 ++--
 addressbook/tests/ebook/ebook-test-utils.h       |    2 +-
 addressbook/tests/ebook/test-changes.c           |    8 +++-----
 addressbook/tests/ebook/test-ebook-add-contact.c |    2 +-
 addressbook/tests/ebook/test-ebook-get-contact.c |    3 +--
 5 files changed, 8 insertions(+), 11 deletions(-)
---
diff --git a/addressbook/tests/ebook/ebook-test-utils.c b/addressbook/tests/ebook/ebook-test-utils.c
index 5c085ae..a9a5245 100644
--- a/addressbook/tests/ebook/ebook-test-utils.c
+++ b/addressbook/tests/ebook/ebook-test-utils.c
@@ -6,7 +6,7 @@
 
 #include "ebook-test-utils.h"
 
-char*
+const char*
 ebook_test_utils_book_add_contact (EBook    *book,
                                    EContact *contact)
 {
@@ -21,7 +21,7 @@ ebook_test_utils_book_add_contact (EBook    *book,
                 exit(1);
         }
 
-        return e_contact_get (contact, E_CONTACT_UID);
+        return e_contact_get_const (contact, E_CONTACT_UID);
 }
 
 static void
diff --git a/addressbook/tests/ebook/ebook-test-utils.h b/addressbook/tests/ebook/ebook-test-utils.h
index 516a6bf..3a57535 100644
--- a/addressbook/tests/ebook/ebook-test-utils.h
+++ b/addressbook/tests/ebook/ebook-test-utils.h
@@ -40,7 +40,7 @@ typedef struct {
 EBook*
 ebook_test_utils_book_new_temp (char **uri);
 
-char*
+const char*
 ebook_test_utils_book_add_contact (EBook    *book,
                                    EContact *contact);
 void
diff --git a/addressbook/tests/ebook/test-changes.c b/addressbook/tests/ebook/test-changes.c
index 017f4b8..e68633e 100644
--- a/addressbook/tests/ebook/test-changes.c
+++ b/addressbook/tests/ebook/test-changes.c
@@ -35,10 +35,7 @@ main (gint argc, gchar **argv)
 
 	/* make a change to the book */
 	contact = e_contact_new_from_vcard (NEW_VCARD);
-	if (!e_book_add_contact (book, contact, &error)) {
-		printf ("failed to add new contact: %s\n", error->message);
-		exit(0);
-	}
+	ebook_test_utils_book_add_contact (book, contact);
 
 	/* get another change set */
 	if (!e_book_get_changes (book, "changeidtest", &changes, &error)) {
@@ -62,7 +59,8 @@ main (gint argc, gchar **argv)
 
 	e_book_free_change_list (changes);
 
-        ebook_test_utils_book_remove (book);
+	g_object_unref (contact);
+	ebook_test_utils_book_remove (book);
 
 	return 0;
 }
diff --git a/addressbook/tests/ebook/test-ebook-add-contact.c b/addressbook/tests/ebook/test-ebook-add-contact.c
index 5e23c46..1e3ac72 100644
--- a/addressbook/tests/ebook/test-ebook-add-contact.c
+++ b/addressbook/tests/ebook/test-ebook-add-contact.c
@@ -24,7 +24,7 @@ main (gint argc, gchar **argv)
         ebook_test_utils_book_open (book, FALSE);
 
         contact = e_contact_new_from_vcard (EBOOK_TEST_UTILS_VCARD_SIMPLE);
-        uid = ebook_test_utils_book_add_contact (book, contact);
+        uid = g_strdup (ebook_test_utils_book_add_contact (book, contact));
 
         /*
          * Sync version
diff --git a/addressbook/tests/ebook/test-ebook-get-contact.c b/addressbook/tests/ebook/test-ebook-get-contact.c
index f6c2c49..f71fdeb 100644
--- a/addressbook/tests/ebook/test-ebook-get-contact.c
+++ b/addressbook/tests/ebook/test-ebook-get-contact.c
@@ -12,7 +12,7 @@ main (gint argc, gchar **argv)
         GMainLoop *loop;
         EContact *contact;
         EContact *contact_final;
-        char *uid;
+        const char *uid;
         const char *contact_final_uid;
 
 	g_type_init ();
@@ -55,7 +55,6 @@ main (gint argc, gchar **argv)
         loop = g_main_loop_new (NULL, TRUE);
         ebook_test_utils_book_async_get_contact (book, uid,
                         (GSourceFunc) g_main_loop_quit, loop);
-        g_free (uid);
         g_main_loop_run (loop);
 
         ebook_test_utils_book_remove (book);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]