[Xfce4-commits] <midori:master> Slice allocations in addons, net, scrolled, transferbar

Christian Dywan noreply at xfce.org
Thu Oct 21 21:10:05 CEST 2010


Updating branch refs/heads/master
         to 68c12e950ec45990698a6c10db9b5522d0923de6 (commit)
       from 45ebf4dcdb5edbd6ea07408644915f9a8b42d8fc (commit)

commit 68c12e950ec45990698a6c10db9b5522d0923de6
Author: Christian Dywan <christian at twotoasts.de>
Date:   Thu Oct 21 21:05:36 2010 +0200

    Slice allocations in addons, net, scrolled, transferbar

 extensions/addons.c           |    8 ++++----
 katze/katze-http-auth.c       |   18 +++++++-----------
 katze/katze-net.c             |   14 +++++---------
 katze/katze-scrolled.c        |    4 ++--
 midori/midori-view.c          |    4 ++--
 toolbars/midori-transferbar.c |    4 ++--
 6 files changed, 22 insertions(+), 30 deletions(-)

diff --git a/extensions/addons.c b/extensions/addons.c
index b3b5d0d..9242686 100644
--- a/extensions/addons.c
+++ b/extensions/addons.c
@@ -527,6 +527,7 @@ addons_free_elements (GSList* elements)
         g_free (element->script_content);
         g_slist_free (element->includes);
         g_slist_free (element->excludes);
+        g_slice_free (struct AddonElement, element);
 
         elements = g_slist_next (elements);
     }
@@ -998,7 +999,7 @@ addons_update_elements (MidoriExtension* extension,
         gchar* tooltip;
 
         fullpath = addon_files->data;
-        element = g_new (struct AddonElement, 1);
+        element = g_slice_new (struct AddonElement);
         element->displayname = g_filename_display_basename (fullpath);
         element->fullpath = fullpath;
         element->enabled = TRUE;
@@ -1065,9 +1066,8 @@ addons_update_elements (MidoriExtension* extension,
     g_free (config_file);
     g_key_file_free (keyfile);
 
-    if (addons_list)
-        g_free (addons_list);
-    addons_list = g_new (struct AddonsList, 1);
+    g_slice_free (struct AddonsList, addons_list);
+    addons_list = g_slice_new (struct AddonsList);
     addons_list->elements = elements;
     addons_list->liststore = liststore;
 
diff --git a/katze/katze-http-auth.c b/katze/katze-http-auth.c
index 2f5db2d..7227bf2 100644
--- a/katze/katze-http-auth.c
+++ b/katze/katze-http-auth.c
@@ -103,8 +103,7 @@ authentication_message_got_headers_cb (SoupMessage*       msg,
 
         if (!g_hash_table_lookup (save->http_auth->logins, opaque_info))
         {
-            KatzeHttpAuthLogin* login;
-            login = g_new (KatzeHttpAuthLogin, 1);
+            KatzeHttpAuthLogin* login = g_slice_new (KatzeHttpAuthLogin);
             login->username = save->username;
             login->password = save->password;
             g_hash_table_insert (save->http_auth->logins, opaque_info, login);
@@ -130,7 +129,7 @@ authentication_message_got_headers_cb (SoupMessage*       msg,
     }
 
     /* FIXME g_object_unref (save->auth); */
-    /* FIXME g_free (save); */
+    /* FIXME g_slice_free (KatzeHttpAuthSave, save); */
     g_signal_handlers_disconnect_by_func (msg,
         authentication_message_got_headers_cb, save);
 }
@@ -164,7 +163,7 @@ authentication_dialog_response_cb (GtkWidget*         dialog,
         else
         {
             g_object_unref (save->auth);
-            g_free (save);
+            g_slice_free (KatzeHttpAuthSave, save);
         }
     }
 
@@ -280,7 +279,7 @@ katze_http_auth_session_authenticate_cb (SoupSession*   session,
     g_object_set_data (G_OBJECT (dialog), "session", session);
     g_object_set_data (G_OBJECT (dialog), "msg", msg);
 
-    save = g_new (KatzeHttpAuthSave, 1);
+    save = g_slice_new0 (KatzeHttpAuthSave);
     save->http_auth = http_auth;
     save->auth = g_object_ref (auth);
     g_signal_connect (dialog, "response",
@@ -366,7 +365,7 @@ katze_http_auth_login_free (KatzeHttpAuthLogin* login)
 {
     g_free (login->username);
     g_free (login->password);
-    g_free (login);
+    g_slice_free (KatzeHttpAuthLogin, login);
 }
 
 static void
@@ -389,12 +388,9 @@ katze_http_auth_set_filename (KatzeHttpAuth* http_auth,
             gchar** parts = g_strsplit (line, "\t", 3);
             if (parts && parts[0] && parts[1] && parts[2])
             {
-                KatzeHttpAuthLogin* login;
-                gint length;
-
-                login = g_new (KatzeHttpAuthLogin, 1);
+                gint length = strlen (parts[2]);
+                KatzeHttpAuthLogin* login = g_slice_new (KatzeHttpAuthLogin);
                 login->username = parts[1];
-                length = strlen (parts[2]);
                 if (parts[2][length - 1] == '\n')
                     length--;
                 login->password = g_strndup (parts[2], length);
diff --git a/katze/katze-net.c b/katze/katze-net.c
index 7efaad4..6bb457e 100644
--- a/katze/katze-net.c
+++ b/katze/katze-net.c
@@ -95,16 +95,12 @@ typedef struct
 static void
 katze_net_priv_free (KatzeNetPriv* priv)
 {
-    KatzeNetRequest* request;
-
-    request = priv->request;
-
+    KatzeNetRequest* request = priv->request;
     g_free (request->uri);
     g_free (request->mime_type);
     g_free (request->data);
-
-    g_free (request);
-    g_free (priv);
+    g_slice_free (KatzeNetRequest, request);
+    g_slice_free (KatzeNetPriv, priv);
 }
 
 gchar*
@@ -276,12 +272,12 @@ katze_net_load_uri (KatzeNet*          net,
     if (!status_cb && !transfer_cb)
         return;
 
-    request = g_new0 (KatzeNetRequest, 1);
+    request = g_slice_new (KatzeNetRequest);
     request->uri = g_strdup (uri);
     request->mime_type = NULL;
     request->data = NULL;
 
-    priv = g_new0 (KatzeNetPriv, 1);
+    priv = g_slice_new (KatzeNetPriv);
     priv->status_cb = status_cb;
     priv->transfer_cb = transfer_cb;
     priv->user_data = user_data;
diff --git a/katze/katze-scrolled.c b/katze/katze-scrolled.c
index 5ec9847..6d2109d 100644
--- a/katze/katze-scrolled.c
+++ b/katze/katze-scrolled.c
@@ -203,7 +203,7 @@ katze_scrolled_event_handler_func (GdkEvent* event,
     EventHandlerData* data;
     gboolean stop_propagating;
 
-    state = g_new0 (KatzeScrolledState, 1);
+    state = g_slice_new (KatzeScrolledState);
     state->current_event_handler = g_list_first (event_handlers);
     if (state->current_event_handler)
     {
@@ -216,7 +216,7 @@ katze_scrolled_event_handler_func (GdkEvent* event,
     else
         gtk_main_do_event (event);
 
-    g_free (state);
+    g_slice_free (KatzeScrolledState, state);
 }
 
 static GdkWindow* current_gdk_window;
diff --git a/midori/midori-view.c b/midori/midori-view.c
index c753419..f365eb8 100644
--- a/midori/midori-view.c
+++ b/midori/midori-view.c
@@ -764,7 +764,7 @@ katze_net_icon_priv_free (KatzeNetIconPriv* priv)
 {
     g_free (priv->icon_file);
     g_free (priv->icon_uri);
-    g_free (priv);
+    g_slice_free (KatzeNetIconPriv, priv);
 }
 
 static gboolean
@@ -896,7 +896,7 @@ _midori_web_view_load_icon (MidoriView* view)
         }
         else
         {
-            priv = g_new0 (KatzeNetIconPriv, 1);
+            priv = g_slice_new (KatzeNetIconPriv);
             priv->icon_file = icon_file;
             priv->icon_uri = icon_uri;
             priv->view = view;
diff --git a/toolbars/midori-transferbar.c b/toolbars/midori-transferbar.c
index f59d333..717443e 100644
--- a/toolbars/midori-transferbar.c
+++ b/toolbars/midori-transferbar.c
@@ -55,7 +55,7 @@ midori_transferbar_info_free (gpointer data)
     transferbar->infos = g_list_remove (transferbar->infos, info);
     g_object_unref (info->download);
     gtk_widget_destroy (info->toolitem);
-    g_free (info);
+    g_slice_free (TransferInfo, info);
 
     if (!transferbar->infos || !g_list_nth_data (transferbar->infos, 0))
         gtk_widget_hide (GTK_WIDGET (transferbar->clear));
@@ -210,7 +210,7 @@ midori_transferbar_add_download_item (MidoriTransferbar* transferbar,
     gtk_toolbar_insert (GTK_TOOLBAR (transferbar), toolitem, 0);
     gtk_widget_show (GTK_WIDGET (transferbar->clear));
 
-    info = g_new (TransferInfo, 1);
+    info = g_slice_new (TransferInfo);
     info->download = g_object_ref (download);
     info->button = button;
     info->toolitem = GTK_WIDGET (toolitem);



More information about the Xfce4-commits mailing list