[PATCH 3/3] migrate seahorse-agent to slice allocator



Signed-off-by: Saleem Abdulrasool <compnerd compnerd org>
---
 agent/seahorse-agent-actions.c |   15 ++-------------
 agent/seahorse-agent-cache.c   |   16 +++-------------
 agent/seahorse-agent-io.c      |   15 ++-------------
 3 files changed, 7 insertions(+), 39 deletions(-)
diff --git a/agent/seahorse-agent-actions.c b/agent/seahorse-agent-actions.c
index a572058..3d4a414 100644
--- a/agent/seahorse-agent-actions.c
+++ b/agent/seahorse-agent-actions.c
@@ -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 @@ encode_password (const gchar *pass)
 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 @@ seahorse_agent_actions_uninit ()
         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 @@ seahorse_agent_actions_getpass (SeahorseAgentConn *rq, guint32 flags, gchar *id,
     }
 
     /* 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 @@ free_passreq (SeahorseAgentPassReq * pr)
     /* 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) */
diff --git a/agent/seahorse-agent-cache.c b/agent/seahorse-agent-cache.c
index ceb01cf..a4371d8 100644
--- a/agent/seahorse-agent-cache.c
+++ b/agent/seahorse-agent-cache.c
@@ -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 @@ typedef struct sa_cache_t {
 } 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 @@ destroy_cache_item (gpointer data)
         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 @@ seahorse_agent_cache_init ()
     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 @@ seahorse_agent_cache_uninit ()
         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 @@ seahorse_agent_internal_set (const gchar *id, const gchar *pass, gboolean lock)
 
     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;
     }
diff --git a/agent/seahorse-agent-io.c b/agent/seahorse-agent-io.c
index ce229b4..b10434f 100644
--- a/agent/seahorse-agent-io.c
+++ b/agent/seahorse-agent-io.c
@@ -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 @@ gboolean seahorse_agent_any_display = FALSE;
  */
 
 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 @@ free_conn (SeahorseAgentConn *cn)
     }
 
     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 @@ connect_handler (GIOChannel *source, GIOCondition cond, gpointer data)
         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 @@ seahorse_agent_io_init ()
     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 @@ seahorse_agent_io_uninit ()
         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]