aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/backend
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-03-29 09:38:45 +0800
committerChris Lahey <clahey@src.gnome.org>2000-03-29 09:38:45 +0800
commit68b4d99fcb3d2ddf45cf0c004d3a0bac341f9616 (patch)
tree103ed00062df4872d4f3daf165523a91866bce5a /addressbook/backend
parentb88b59741fd9d2bc4097b803db4447e15d004d79 (diff)
downloadgsoc2013-evolution-68b4d99fcb3d2ddf45cf0c004d3a0bac341f9616.tar.gz
gsoc2013-evolution-68b4d99fcb3d2ddf45cf0c004d3a0bac341f9616.tar.zst
gsoc2013-evolution-68b4d99fcb3d2ddf45cf0c004d3a0bac341f9616.zip
Fixed memory allocation.
2000-03-28 Christopher James Lahey <clahey@helixcode.com> * addressbook/backend/pas/pas-card-cursor.c: Fixed memory allocation. * addressbook/backend/pas/pas-backend-file.c: Fixed memory allocation. Made database stuff not do an extra entry. * addressbook/backend/ebook/test-client.c: Add test for get_all_cards functionality. Changed database name to test.db. * addressbook/backend/ebook/e-card-cursor.c: Changed bonobo_object to gtk_object in a couple of places. svn path=/trunk/; revision=2236
Diffstat (limited to 'addressbook/backend')
-rw-r--r--addressbook/backend/ebook/e-card-cursor.c4
-rw-r--r--addressbook/backend/ebook/test-client.c6
-rw-r--r--addressbook/backend/pas/pas-backend-file.c23
-rw-r--r--addressbook/backend/pas/pas-card-cursor.c11
4 files changed, 23 insertions, 21 deletions
diff --git a/addressbook/backend/ebook/e-card-cursor.c b/addressbook/backend/ebook/e-card-cursor.c
index 7a51698d54..fc9cf051dc 100644
--- a/addressbook/backend/ebook/e-card-cursor.c
+++ b/addressbook/backend/ebook/e-card-cursor.c
@@ -7,7 +7,7 @@
*/
#include <config.h>
-#include <bonobo.h>
+#include <gtk/gtk.h>
#include "addressbook.h"
#include "e-card-cursor.h"
@@ -118,7 +118,7 @@ e_card_cursor_class_init (ECardCursorClass *klass)
{
GtkObjectClass *object_class = (GtkObjectClass *) klass;
- parent_class = gtk_type_class (bonobo_object_get_type ());
+ parent_class = gtk_type_class (gtk_object_get_type ());
object_class->destroy = e_card_cursor_destroy;
}
diff --git a/addressbook/backend/ebook/test-client.c b/addressbook/backend/ebook/test-client.c
index 945df3f53c..b99ebdae5e 100644
--- a/addressbook/backend/ebook/test-client.c
+++ b/addressbook/backend/ebook/test-client.c
@@ -48,7 +48,6 @@ init_bonobo (int argc, char **argv)
}
-#if 0
static void
get_cursor_cb (EBook *book, EBookStatus status, ECardCursor *cursor, gpointer closure)
{
@@ -64,7 +63,6 @@ get_cursor_cb (EBook *book, EBookStatus status, ECardCursor *cursor, gpointer cl
}
gtk_object_unref(GTK_OBJECT(cursor));
}
-#endif
static void
add_card_cb (EBook *book, EBookStatus status, const gchar *id, gpointer closure)
@@ -88,9 +86,7 @@ add_card_cb (EBook *book, EBookStatus status, const gchar *id, gpointer closure)
g_free(vcard);
gtk_object_unref(GTK_OBJECT(card));
-#if 0
e_book_get_all_cards(book, get_cursor_cb, NULL);
-#endif
}
static void
@@ -106,7 +102,7 @@ ebook_create (void)
book = e_book_new ();
- if (! e_book_load_uri (book, "file:/tmp/test.txt", book_open_cb, NULL)) {
+ if (! e_book_load_uri (book, "file:/tmp/test.db", book_open_cb, NULL)) {
printf ("error calling load_uri!\n");
}
diff --git a/addressbook/backend/pas/pas-backend-file.c b/addressbook/backend/pas/pas-backend-file.c
index e117fe8b05..73f4f67fc9 100644
--- a/addressbook/backend/pas/pas-backend-file.c
+++ b/addressbook/backend/pas/pas-backend-file.c
@@ -54,7 +54,7 @@ get_nth(PASCardCursor *cursor, long n, gpointer data)
PASBackendFileCursorPrivate *cursor_data = (PASBackendFileCursorPrivate *) data;
GList *nth_item = g_list_nth(cursor_data->elements, n);
- return (char*)nth_item->data;
+ return g_strdup((char*)nth_item->data);
}
static void
@@ -220,13 +220,14 @@ pas_backend_file_build_all_cards_list(PASBackend *backend,
PASBackendFile *bf = PAS_BACKEND_FILE (backend);
DB *db = bf->priv->file_db;
int db_error;
-
- cursor_data->elements = NULL;
- do {
- DBT id_dbt, vcard_dbt;
- char *id;
+ DBT id_dbt, vcard_dbt;
+ char *id;
- db_error = db->seq(db, &id_dbt, &vcard_dbt, R_NEXT);
+ cursor_data->elements = NULL;
+
+ db_error = db->seq(db, &id_dbt, &vcard_dbt, R_NEXT);
+
+ while (db_error == 0) {
id = g_strndup(id_dbt.data, id_dbt.size);
@@ -237,11 +238,13 @@ pas_backend_file_build_all_cards_list(PASBackend *backend,
}
else {
g_free(id);
- g_list_append(cursor_data->elements, g_strndup(vcard_dbt.data,
- vcard_dbt.size));
+ cursor_data->elements = g_list_append(cursor_data->elements, g_strndup(vcard_dbt.data,
+ vcard_dbt.size));
}
- } while (db_error == 0);
+ db_error = db->seq(db, &id_dbt, &vcard_dbt, R_NEXT);
+
+ }
if (db_error == -1) {
g_warning ("pas_backend_file_build_all_cards_list: error building list\n");
diff --git a/addressbook/backend/pas/pas-card-cursor.c b/addressbook/backend/pas/pas-card-cursor.c
index b6ef91f41c..3f66848332 100644
--- a/addressbook/backend/pas/pas-card-cursor.c
+++ b/addressbook/backend/pas/pas-card-cursor.c
@@ -64,10 +64,13 @@ impl_pas_card_cursor_get_nth (PortableServer_Servant servant,
CORBA_Environment *ev)
{
PASCardCursor *cursor = PAS_CARD_CURSOR (bonobo_object_from_servant (servant));
- if ( cursor->priv->get_nth )
- return cursor->priv->get_nth( cursor, n, cursor->priv->data );
- else
- return "";
+ if ( cursor->priv->get_nth ) {
+ char *vcard = cursor->priv->get_nth( cursor, n, cursor->priv->data );
+ char *retval = CORBA_string_dup (vcard);
+ g_free (vcard);
+ return retval;
+ } else
+ return CORBA_string_dup ("");
}
/*