diff options
author | Rodrigo Moya <rodrigo@ximian.com> | 2001-02-17 01:05:28 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@src.gnome.org> | 2001-02-17 01:05:28 +0800 |
commit | e7eaef416a6864ef0c9467e8d2757879f5c087ad (patch) | |
tree | 90bed896a67fc3f259173b6bb639b57e6a146692 /calendar/pcs/cal-backend-db.c | |
parent | 4bb5f791c7ecf4453528994ec98759ac33f0b39d (diff) | |
download | gsoc2013-evolution-e7eaef416a6864ef0c9467e8d2757879f5c087ad.tar.gz gsoc2013-evolution-e7eaef416a6864ef0c9467e8d2757879f5c087ad.tar.zst gsoc2013-evolution-e7eaef416a6864ef0c9467e8d2757879f5c087ad.zip |
close DB environment. Some compilation warnings removed
2001-02-16 Rodrigo Moya <rodrigo@ximian.com>
* pcs/calbackend-db.c (cal_backend_db_destroy): close DB environment.
Some compilation warnings removed
svn path=/trunk/; revision=8254
Diffstat (limited to 'calendar/pcs/cal-backend-db.c')
-rw-r--r-- | calendar/pcs/cal-backend-db.c | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/calendar/pcs/cal-backend-db.c b/calendar/pcs/cal-backend-db.c index 049cf4d5c7..e83b6fd3d1 100644 --- a/calendar/pcs/cal-backend-db.c +++ b/calendar/pcs/cal-backend-db.c @@ -35,9 +35,10 @@ typedef struct { gint ref; DBC* dbc; DB* parent_db; - /* TODO: convert into a hash table */ - GList* keys; - GList* data; + + /* data in the cursor */ + GList *keys; + GList *data; } CalBackendDBCursor; /* private part of the CalBackendDB structure */ @@ -204,6 +205,10 @@ cal_backend_db_destroy (GtkObject *object) if (cbdb->priv->history_db) cbdb->priv->history_db->close(cbdb->priv->history_db, 0); + /* close DB environment */ + if (cbdb->priv->environment) + cbdb->priv->environment->close(cbdb->priv->environment, 0); + g_free((gpointer) priv); cbdb->priv = NULL; @@ -275,9 +280,15 @@ open_cursor (CalBackendDB *cbdb, DB *db) DBT data; /* read data */ + memset(&key, 0, sizeof(key)); + memset(&data, 0, sizeof(data)); + while ((ret = cursor->dbc->c_get(cursor->dbc, &key, &data, DB_NEXT)) == 0) { cursor->keys = g_list_append(cursor->keys, g_memdup(&key, sizeof(key))); cursor->data = g_list_append(cursor->data, g_memdup(&data, sizeof(data))); + + memset(&key, 0, sizeof(key)); + memset(&data, 0, sizeof(data)); } if (ret == DB_NOTFOUND) { cbdb->priv->cursors = g_list_prepend(cbdb->priv->cursors, (gpointer) cursor); @@ -303,6 +314,7 @@ find_cursor_by_db (CalBackendDB *cbdb, DB *db) for (node = g_list_first(cbdb->priv->cursors); node != NULL; node = g_list_next(node)) { CalBackendDBCursor* cursor = (CalBackendDBCursor *) node->data; + if (cursor && cursor->parent_db == db) return cursor; } @@ -315,21 +327,23 @@ static DBT * find_record_by_id (CalBackendDBCursor *cursor, const gchar *id) { GList *node; - gint pos = 0; g_return_val_if_fail(cursor != NULL, NULL); g_return_val_if_fail(id != NULL, NULL); + for (node = g_list_first(cursor->keys); node != NULL; node = g_list_next(node)) { - DBT* key = (DBT *) node->data; - if (key) { - if (!strcmp((gchar *) key->data, id)) { - GList* tmp = g_list_nth(cursor->data, pos); - if (tmp) - return (DBT *) node->data; - } + DBT *key; + + key = (DBT *) node->data; + if (key && !strcmp(key->data, id)) { + GList *tmp; + + tmp = g_list_nth(cursor->data, g_list_position(cursor->keys, node)); + if (tmp) + return (DBT *) tmp->data; + return NULL; /* no data associated with this key */ } - pos++; } return NULL; /* not found */ @@ -1336,7 +1350,7 @@ cal_backend_db_get_alarms_for_object (CalBackend *backend, /* do notifications to Cal clients */ static void -do_notify (CalBackendDB *cbdb, void (*notify_fn)(Cal *, gchar *), gchar *uid) +do_notify (CalBackendDB *cbdb, void (*notify_fn)(Cal *, gchar *), const gchar *uid) { GList *node; @@ -1350,7 +1364,7 @@ do_notify (CalBackendDB *cbdb, void (*notify_fn)(Cal *, gchar *), gchar *uid) Cal *cal; cal = CAL(node->data); - (*notify_fn)(cal, uid); + (*notify_fn)(cal, (gpointer) uid); } } |