Author: benny
Date: 2006-07-25 23:03:26 +0000 (Tue, 25 Jul 2006)
New Revision: 22527

Modified:
   libexo/trunk/ChangeLog
   libexo/trunk/exo/exo-binding.c
   libexo/trunk/exo/exo-icon-bar.c
   libexo/trunk/exo/exo-icon-view.c
   libexo/trunk/exo/exo-md5.c
   libexo/trunk/exo/exo-private.h
   libexo/trunk/exo/exo-toolbars-model.c
   libexo/trunk/exo/exo-xsession-client.c
Log:
2006-07-26      Benedikt Meurer <[EMAIL PROTECTED]>

        * exo/exo-xsession-client.c(exo_xsession_client_set_group): Use the
          stack to allocate the temporary custom protocols.
        * exo/exo-private.h: Add support macros for the slice allocator.
        * exo/exo-binding.c, exo/exo-icon-bar.c, exo/exo-icon-view.c,
          exo/exo-md5.c, exo/exo-toolbars-model.c: Use the slice allocator
          to reduce memory overhead where possible.




Modified: libexo/trunk/ChangeLog
===================================================================
--- libexo/trunk/ChangeLog      2006-07-25 07:58:55 UTC (rev 22526)
+++ libexo/trunk/ChangeLog      2006-07-25 23:03:26 UTC (rev 22527)
@@ -1,3 +1,12 @@
+2006-07-26     Benedikt Meurer <[EMAIL PROTECTED]>
+
+       * exo/exo-xsession-client.c(exo_xsession_client_set_group): Use the
+         stack to allocate the temporary custom protocols.
+       * exo/exo-private.h: Add support macros for the slice allocator.
+       * exo/exo-binding.c, exo/exo-icon-bar.c, exo/exo-icon-view.c,
+         exo/exo-md5.c, exo/exo-toolbars-model.c: Use the slice allocator
+         to reduce memory overhead where possible.
+
 2006-07-09     Benedikt Meurer <[EMAIL PROTECTED]>
 
        * configure.in.in: Post-release version bump.

Modified: libexo/trunk/exo/exo-binding.c
===================================================================
--- libexo/trunk/exo/exo-binding.c      2006-07-25 07:58:55 UTC (rev 22526)
+++ libexo/trunk/exo/exo-binding.c      2006-07-25 23:03:26 UTC (rev 22527)
@@ -1,7 +1,7 @@
 /* $Id$ */
 /*-
- * Copyright (c) 2004 os-cillation e.K.
- * Copyright (c) 2004 Victor Porton (http://ex-code.com/~porton/)
+ * Copyright (c) 2004-2006 os-cillation e.K.
+ * Copyright (c) 2004      Victor Porton (http://ex-code.com/~porton/)
  *
  * Written by Benedikt Meurer <[EMAIL PROTECTED]>.
  *
@@ -27,6 +27,7 @@
 
 #include <exo/exo-binding.h>
 #include <exo/exo-gobject-extensions.h>
+#include <exo/exo-private.h>
 #include <exo/exo-alias.h>
 
 
@@ -121,7 +122,7 @@
   if (link->dst_object != NULL)
     g_object_weak_unref (link->dst_object, exo_binding_on_dst_object_destroy, 
binding);
 
-  g_free (binding);
+  _exo_slice_free (ExoBinding, binding);
 }
 
 
@@ -145,7 +146,7 @@
         binding->base.destroy (binding->direct.user_data);
       binding->direct.dst_object = NULL;
       g_signal_handler_disconnect (object2, binding->reverse.handler);
-      g_free (binding);
+      _exo_slice_free (ExoMutualBinding, binding);
     }
 }
 
@@ -281,7 +282,7 @@
                                 transform,
                                 user_data);
 
-  binding = g_new (ExoBinding, 1);
+  binding = _exo_slice_new (ExoBinding);
   binding->src_object = src_object;
   binding->base.destroy = destroy_notify;
 
@@ -431,7 +432,7 @@
                                 transform,
                                 user_data);
 
-  binding = g_new (ExoMutualBinding, 1);
+  binding = _exo_slice_new (ExoMutualBinding);
   binding->base.destroy = destroy_notify;
 
   exo_binding_link_init (&binding->direct,

Modified: libexo/trunk/exo/exo-icon-bar.c
===================================================================
--- libexo/trunk/exo/exo-icon-bar.c     2006-07-25 07:58:55 UTC (rev 22526)
+++ libexo/trunk/exo/exo-icon-bar.c     2006-07-25 23:03:26 UTC (rev 22527)
@@ -1244,7 +1244,7 @@
 {
   ExoIconBarItem *item;
 
-  item = g_new0 (ExoIconBarItem, 1);
+  item = _exo_slice_new0 (ExoIconBarItem);
   item->width = -1;
   item->height = -1;
 
@@ -1256,7 +1256,7 @@
 static void
 exo_icon_bar_item_free (ExoIconBarItem *item)
 {
-  g_free (item);
+  _exo_slice_free (ExoIconBarItem, item);
 }
 
 

Modified: libexo/trunk/exo/exo-icon-view.c
===================================================================
--- libexo/trunk/exo/exo-icon-view.c    2006-07-25 07:58:55 UTC (rev 22526)
+++ libexo/trunk/exo/exo-icon-view.c    2006-07-25 23:03:26 UTC (rev 22527)
@@ -402,8 +402,6 @@
 {
   GtkTreeIter iter;
   
-  gint row, col;
-
   /* Bounding box */
   GdkRectangle area;
 
@@ -418,6 +416,8 @@
   gint *before;
   gint *after;
 
+  guint row : (sizeof (guint) / 2) - 1;
+  guint col : (sizeof (guint) / 2) - 1;
   guint selected : 1;
   guint selected_before_rubberbanding : 1;
 };
@@ -437,7 +437,6 @@
 
   GtkTreeModel *model;
   
-  GMemChunk *items_chunk;
   GList *items;
   
   GtkAdjustment *hadjustment;
@@ -1143,8 +1142,6 @@
 {
   icon_view->priv = EXO_ICON_VIEW_GET_PRIVATE (icon_view);
   
-  icon_view->priv->items_chunk = g_mem_chunk_create (ExoIconViewItem, 512, 
G_ALLOC_ONLY);
-
   icon_view->priv->width = 0;
   icon_view->priv->height = 0;
   icon_view->priv->selection_mode = GTK_SELECTION_SINGLE;
@@ -1243,9 +1240,6 @@
   /* drop the cell renderers */
   exo_icon_view_cell_layout_clear (GTK_CELL_LAYOUT (icon_view));
 
-  /* drop the items chunk */
-  g_mem_chunk_destroy (icon_view->priv->items_chunk);
-
   /* be sure to cancel the single click timeout */
   if (G_UNLIKELY (icon_view->priv->single_click_timeout_id >= 0))
     g_source_remove (icon_view->priv->single_click_timeout_id);
@@ -1943,7 +1937,7 @@
         {
           icon_view->priv->children = g_list_delete_link 
(icon_view->priv->children, lp);
           gtk_widget_unparent (widget);
-          g_free (child);
+          _exo_slice_free (ExoIconViewChild, child);
           return;
         }
     }
@@ -2007,7 +2001,7 @@
   ExoIconViewChild *child;
   
   /* allocate the new child */
-  child = g_new (ExoIconViewChild, 1);
+  child = _exo_slice_new (ExoIconViewChild);
   child->widget = widget;
   child->item = item;
   child->cell = cell;
@@ -3808,7 +3802,7 @@
   index = gtk_tree_path_get_indices (path)[0];
 
   /* allocate the new item */
-  item = g_chunk_new0 (ExoIconViewItem, icon_view->priv->items_chunk);
+  item = _exo_slice_new0 (ExoIconViewItem);
   item->iter = *iter;
   item->area.width = -1;
   item->area.height = -1;
@@ -3868,9 +3862,8 @@
   /* drop the item from the list */
   icon_view->priv->items = g_list_delete_link (icon_view->priv->items, list);
 
-  /* reset the item chunk if this was the last item */
-  if (G_UNLIKELY (icon_view->priv->items == NULL))
-    g_mem_chunk_reset (icon_view->priv->items_chunk);
+  /* release the item */
+  _exo_slice_free (ExoIconViewItem, item);
 
   /* recalculate the layout */
   exo_icon_view_queue_layout (icon_view);
@@ -4594,9 +4587,9 @@
   if (G_UNLIKELY (info->destroy != NULL))
     (*info->destroy) (info->func_data);
 
-  g_object_unref (G_OBJECT (info->cell));
   free_cell_attributes (info);
-  g_free (info);
+  g_object_unref (G_OBJECT (info->cell));
+  _exo_slice_free (ExoIconViewCellInfo, info);
 }
 
 
@@ -4615,7 +4608,7 @@
   g_object_ref (renderer);
   gtk_object_sink (GTK_OBJECT (renderer));
 
-  info = g_new0 (ExoIconViewCellInfo, 1);
+  info = _exo_slice_new0 (ExoIconViewCellInfo);
   info->cell = renderer;
   info->expand = expand ? TRUE : FALSE;
   info->pack = GTK_PACK_START;
@@ -4643,7 +4636,7 @@
   g_object_ref (renderer);
   gtk_object_sink (GTK_OBJECT (renderer));
 
-  info = g_new0 (ExoIconViewCellInfo, 1);
+  info = _exo_slice_new0 (ExoIconViewCellInfo);
   info->cell = renderer;
   info->expand = expand ? TRUE : FALSE;
   info->pack = GTK_PACK_END;
@@ -5198,13 +5191,13 @@
 
       /* drop all items belonging to the previous model */
       for (lp = icon_view->priv->items; lp != NULL; lp = lp->next)
-        g_free (EXO_ICON_VIEW_ITEM (lp->data)->box);
+        {
+          g_free (EXO_ICON_VIEW_ITEM (lp->data)->box);
+          _exo_slice_free (ExoIconViewItem, lp->data);
+        }
       g_list_free (icon_view->priv->items);
       icon_view->priv->items = NULL;
 
-      /* reset the item memory chunk as there are no items left now */
-      g_mem_chunk_reset (icon_view->priv->items_chunk);
-
       /* reset statistics */
       icon_view->priv->search_column = -1;
       icon_view->priv->anchor_item = NULL;
@@ -5270,7 +5263,7 @@
         {
           do
             {
-              item = g_chunk_new0 (ExoIconViewItem, 
icon_view->priv->items_chunk);
+              item = _exo_slice_new0 (ExoIconViewItem);
               item->iter = iter;
               item->area.width = -1;
               item->area.height = -1;
@@ -6429,7 +6422,7 @@
   DestRow *dr = (DestRow *)data;
 
   gtk_tree_row_reference_free (dr->dest_row);
-  g_free (dr);
+  _exo_slice_free (DestRow, dr);
 }
 
 static void
@@ -6449,7 +6442,7 @@
       return;
     }
   
-  dr = g_new0 (DestRow, 1);
+  dr = _exo_slice_new0 (DestRow);
      
   dr->dest_row = gtk_tree_row_reference_new (model, dest_row);
   dr->empty_view_drop = empty_view_drop;

Modified: libexo/trunk/exo/exo-md5.c
===================================================================
--- libexo/trunk/exo/exo-md5.c  2006-07-25 07:58:55 UTC (rev 22526)
+++ libexo/trunk/exo/exo-md5.c  2006-07-25 23:03:26 UTC (rev 22527)
@@ -37,6 +37,7 @@
 #endif
 
 #include <exo/exo-md5.h>
+#include <exo/exo-private.h>
 #include <exo/exo-string.h>
 #include <exo/exo-alias.h>
 
@@ -333,7 +334,7 @@
 
   g_return_val_if_fail (contents != NULL, NULL);
 
-  digest = g_new (ExoMd5Digest, 1);
+  digest = _exo_slice_new (ExoMd5Digest);
   get_md5 (contents, digest->digest);
 
   return digest;
@@ -386,7 +387,7 @@
   g_return_val_if_fail (str_digest != NULL, NULL);
   g_return_val_if_fail (strlen (str_digest) == 32, NULL);
 
-  digest = g_new (ExoMd5Digest, 1);
+  digest = _exo_slice_new (ExoMd5Digest);
   for (n = 0; n < 16; ++n)
     {
       digest->digest[n] =
@@ -463,7 +464,7 @@
 void
 exo_md5_digest_free (ExoMd5Digest *digest)
 {
-  g_free (digest);
+  _exo_slice_free (ExoMd5Digest, digest);
 }
 
 

Modified: libexo/trunk/exo/exo-private.h
===================================================================
--- libexo/trunk/exo/exo-private.h      2006-07-25 07:58:55 UTC (rev 22526)
+++ libexo/trunk/exo/exo-private.h      2006-07-25 23:03:26 UTC (rev 22527)
@@ -20,8 +20,8 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#if !defined (EXO_INSIDE_EXO_H) && !defined (EXO_COMPILATION)
-#error "Only <exo/exo.h> can be included directly, this file may disappear or 
change contents."
+#if !defined (EXO_COMPILATION)
+#error "Only <exo/exo.h> can be included directly, this file is not part of 
the public API."
 #endif
 
 #ifndef __EXO_PRIVATE_H__
@@ -33,6 +33,23 @@
 
 G_BEGIN_DECLS;
 
+/* support macros for the slice allocator */
+#if GLIB_CHECK_VERSION(2,10,0)
+#define _exo_slice_alloc(block_size)             (g_slice_alloc ((block_size)))
+#define _exo_slice_alloc0(block_size)            (g_slice_alloc0 
((block_size)))
+#define _exo_slice_free1(block_size, mem_block)  G_STMT_START{ g_slice_free1 
((block_size), (mem_block)); }G_STMT_END
+#define _exo_slice_new(type)                     (g_slice_new (type))
+#define _exo_slice_new0(type)                    (g_slice_new0 (type))
+#define _exo_slice_free(type, ptr)               G_STMT_START{ g_slice_free 
(type, (ptr)); }G_STMT_END
+#else
+#define _exo_slice_alloc(block_size)             (g_malloc ((block_size)))
+#define _exo_slice_alloc0(block_size)            (g_malloc0 ((block_size)))
+#define _exo_slice_free1(block_size, mem_block)  G_STMT_START{ g_free 
((mem_block)); }G_STMT_END
+#define _exo_slice_new(type)                     (g_new (type, 1))
+#define _exo_slice_new0(type)                    (g_new0 (type, 1))
+#define _exo_slice_free(type, ptr)               G_STMT_START{ g_free ((ptr)); 
}G_STMT_END
+#endif
+
 void  _exo_i18n_init                    (void) G_GNUC_INTERNAL;
 
 void  _exo_gtk_widget_send_focus_change (GtkWidget *widget,

Modified: libexo/trunk/exo/exo-toolbars-model.c
===================================================================
--- libexo/trunk/exo/exo-toolbars-model.c       2006-07-25 07:58:55 UTC (rev 
22526)
+++ libexo/trunk/exo/exo-toolbars-model.c       2006-07-25 23:03:26 UTC (rev 
22527)
@@ -464,7 +464,7 @@
 {
   ExoToolbarsItem *item;
 
-  item = g_new (ExoToolbarsItem, 1);
+  item = _exo_slice_new (ExoToolbarsItem);
   item->id = g_strdup (id);
   item->type = g_strdup (type);
   item->is_separator = is_separator;
@@ -485,12 +485,12 @@
       item = lp->data;
       g_free (item->type);
       g_free (item->id);
-      g_free (item);
+      _exo_slice_free (ExoToolbarsItem, item);
     }
   
   g_list_free (toolbar->items);
   g_free (toolbar->name);
-  g_free (toolbar);
+  _exo_slice_free (ExoToolbarsToolbar, toolbar);
 }
 
 
@@ -1183,7 +1183,7 @@
   g_return_val_if_fail (EXO_IS_TOOLBARS_MODEL (model), -1);
   g_return_val_if_fail (name != NULL, -1);
 
-  toolbar = g_new (ExoToolbarsToolbar, 1);
+  toolbar = _exo_slice_new (ExoToolbarsToolbar);
   toolbar->name = g_strdup (name);
   toolbar->items = NULL;
   toolbar->flags = 0;
@@ -1279,7 +1279,7 @@
   toolbar->items = g_list_remove (toolbar->items, item);
   g_free (item->type);
   g_free (item->id);
-  g_free (item);
+  _exo_slice_free (ExoToolbarsItem, item);
 
   g_signal_emit (G_OBJECT (model), toolbars_model_signals[ITEM_REMOVED],
                  0, toolbar_position, item_position);

Modified: libexo/trunk/exo/exo-xsession-client.c
===================================================================
--- libexo/trunk/exo/exo-xsession-client.c      2006-07-25 07:58:55 UTC (rev 
22526)
+++ libexo/trunk/exo/exo-xsession-client.c      2006-07-25 23:03:26 UTC (rev 
22527)
@@ -1,6 +1,6 @@
 /* $Id$ */
 /*-
- * Copyright (c) 2004-2005 os-cillation e.K.
+ * Copyright (c) 2004-2006 os-cillation e.K.
  *
  * Written by Benedikt Meurer <[EMAIL PROTECTED]>.
  *
@@ -362,7 +362,7 @@
                            GDK_DRAWABLE_XID (leader),
                            &protocols, &nprotocols))
         {
-          protocols_custom = g_new (Atom, nprotocols + 1);
+          protocols_custom = g_newa (Atom, nprotocols + 1);
           memcpy (protocols_custom, protocols, nprotocols * sizeof 
(*protocols));
           protocols_custom[nprotocols++] = client->priv->wm_save_yourself;
 
@@ -371,7 +371,6 @@
                            protocols_custom, nprotocols);
 
           XFree ((void *) protocols);
-          g_free (protocols_custom);
         }
 
       gdk_window_add_filter (leader, exo_xsession_client_filter, client);

_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to