seahorse r2223 - in seahorse-plugins/trunk: . agent



Author: asaleem
Date: Fri May 30 03:10:46 2008
New Revision: 2223
URL: http://svn.gnome.org/viewvc/seahorse?rev=2223&view=rev

Log:
migrate GMemChunk to the slice allocator

Modified:
   seahorse-plugins/trunk/ChangeLog
   seahorse-plugins/trunk/agent/seahorse-agent-actions.c
   seahorse-plugins/trunk/agent/seahorse-agent-cache.c
   seahorse-plugins/trunk/agent/seahorse-agent-io.c

Modified: seahorse-plugins/trunk/agent/seahorse-agent-actions.c
==============================================================================
--- seahorse-plugins/trunk/agent/seahorse-agent-actions.c	(original)
+++ seahorse-plugins/trunk/agent/seahorse-agent-actions.c	Fri May 30 03:10:46 2008
@@ -19,8 +19,6 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#undef G_DISABLE_DEPRECATED
-
 #include <sys/types.h>
 #include <stdlib.h>
 #include <string.h>
@@ -39,7 +37,6 @@
  */
 
 static GQueue *g_queue = NULL;          /* The queue of SeahorseAgentPassReq items */
-static GMemChunk *g_memory = NULL;      /* Allocator for SeahorseAgentPassReq items */
 
 /* -----------------------------------------------------------------------------
  * IMPLEMENTATION
@@ -73,8 +70,6 @@
 void
 seahorse_agent_actions_init ()
 {
-    /* The main memory queue */
-    g_memory = g_mem_chunk_create (SeahorseAgentPassReq, 128, G_ALLOC_AND_FREE);
     g_queue = g_queue_new ();
 }
 
@@ -86,11 +81,6 @@
         g_queue_free (g_queue);
         g_queue = NULL;
     }
-
-    if (g_memory) {
-        g_mem_chunk_destroy (g_memory);
-        g_memory = NULL;
-    }
 }
 
 /* Called for the assuan GET_PASSPHRASE command */
@@ -123,8 +113,7 @@
     }
 
     /* A new queue item */
-    pr = g_chunk_new (SeahorseAgentPassReq, g_memory);
-    memset (pr, 0, sizeof (*pr));
+    pr = g_slice_new0 (SeahorseAgentPassReq);
     pr->flags = flags;
     pr->id = id ? g_strdup (id) : NULL;
     pr->errmsg = errmsg ? g_strdup (errmsg) : NULL;
@@ -152,7 +141,7 @@
     /* Just in case, should already be popped */
     g_queue_remove (g_queue, pr);
 
-    g_chunk_free (pr, g_memory);
+    g_slice_free (SeahorseAgentPassReq, pr);
 }
 
 /* Called when a authorize prompt completes (send back the cached password) */

Modified: seahorse-plugins/trunk/agent/seahorse-agent-cache.c
==============================================================================
--- seahorse-plugins/trunk/agent/seahorse-agent-cache.c	(original)
+++ seahorse-plugins/trunk/agent/seahorse-agent-cache.c	Fri May 30 03:10:46 2008
@@ -19,8 +19,6 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#undef G_DISABLE_DEPRECATED
-
 #include "config.h"
 #include <sys/types.h>
 #include <stdlib.h>
@@ -78,7 +76,6 @@
 } sa_cache_t;
 
 static GHashTable *g_cache = NULL;      /* Hash of ids to sa_cache_t */
-static GMemChunk *g_memory = NULL;      /* Memory for sa_cache_t's */
 static guint g_notify_id = 0;           /* gconf notify id */
 static guint g_timeout_id = 0;          /* timeout of next expire */
 static gpgme_ctx_t g_gpgme_ctx = NULL;  /* GPGME context */
@@ -211,7 +208,7 @@
         if (it->pass)
             gnome_keyring_memory_free (it->pass);
 
-        g_chunk_free (it, g_memory);
+        g_slice_free (sa_cache_t, it);
     }
 }
 
@@ -236,10 +233,9 @@
     gpgme_protocol_t proto = GPGME_PROTOCOL_OpenPGP;
     gpgme_error_t err;
  
-    if ((g_cache == NULL) && (g_memory == NULL)) {
+    if (g_cache == NULL) {
         g_cache =
             g_hash_table_new_full (g_str_hash, g_str_equal, NULL, destroy_cache_item);
-        g_memory = g_mem_chunk_create (SeahorseAgentPassReq, 128, G_ALLOC_AND_FREE);
 
         err = gpgme_engine_check_version (proto);
         g_return_if_fail (GPG_IS_OK (err));
@@ -264,11 +260,6 @@
         g_hash_table_destroy (g_cache);
         g_cache = NULL;
     }
-
-    if (g_memory) {
-        g_mem_chunk_destroy (g_memory);
-        g_memory = NULL;
-    }
     
     if (g_notify_id) {
         seahorse_gconf_unnotify (g_notify_id);
@@ -408,8 +399,7 @@
 
     if (!it) {
         /* Allocate and initialize a new cache item */
-        it = g_chunk_new (sa_cache_t, g_memory);
-        memset (it, 0, sizeof (*it));
+        it = g_slice_new0 (sa_cache_t);
         it->id = g_strdup (id);
         allocated = TRUE;
     }

Modified: seahorse-plugins/trunk/agent/seahorse-agent-io.c
==============================================================================
--- seahorse-plugins/trunk/agent/seahorse-agent-io.c	(original)
+++ seahorse-plugins/trunk/agent/seahorse-agent-io.c	Fri May 30 03:10:46 2008
@@ -19,8 +19,6 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#undef G_DISABLE_DEPRECATED
-
 #include "config.h"
 #include <sys/param.h>
 #include <sys/socket.h>
@@ -66,7 +64,6 @@
  */
 
 static GList *g_connections = NULL;     /* All open connections */
-static GMemChunk *g_memory = NULL;      /* Memory for connections */
 
 static gint g_socket = -1;              /* Socket we're listening on */
 static GIOChannel *g_iochannel = NULL;  /* IO channel for above */
@@ -200,7 +197,7 @@
     }
 
     g_connections = g_list_remove (g_connections, cn);
-    g_chunk_free (cn, g_memory);
+    g_slice_free (SeahorseAgentConn, cn);
 }
 
 /* Is the argument a assuan null parameter? */
@@ -639,7 +636,7 @@
         return TRUE;            /* don't stop listening */
     }
 
-    cn = g_chunk_new0 (SeahorseAgentConn, g_memory);
+    cn = g_slice_new0 (SeahorseAgentConn);
 
     g_connections = g_list_append (g_connections, cn);
 
@@ -678,9 +675,6 @@
     g_io_channel_set_close_on_unref (g_iochannel, TRUE);
     g_iochannel_tag = g_io_add_watch (g_iochannel, G_IO_IN, connect_handler, NULL);
 
-    /* The main memory queue */
-    g_memory = g_mem_chunk_create (SeahorseAgentConn, 8, G_ALLOC_AND_FREE);
-
     return 0;
 }
 
@@ -701,11 +695,6 @@
         g_connections = NULL;
     }
 
-    if (g_memory) {
-        g_mem_chunk_destroy (g_memory);
-        g_memory = NULL;
-    }
-
     if (g_socket) {
         GError *err = NULL;
         gchar *t;



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