[Xfce4-commits] <thunar:master> Use g_slice_ functions directly and drop macros.

Nick Schermer nick at xfce.org
Sat Aug 22 21:20:05 CEST 2009


Updating branch refs/heads/master
         to 293bfc66c650d52d4d87b4f6bc7c9f7bd1278934 (commit)
       from 3cc156932e03c881a9643e917abf42ff3ad4d48a (commit)

commit 293bfc66c650d52d4d87b4f6bc7c9f7bd1278934
Author: Nick Schermer <nick at xfce.org>
Date:   Sat Aug 22 21:11:26 2009 +0200

    Use g_slice_ functions directly and drop macros.

 thunar/thunar-browser.c           |    8 ++++----
 thunar/thunar-clipboard-manager.c |    4 ++--
 thunar/thunar-exec.c              |    4 ++--
 thunar/thunar-launcher.c          |    8 ++++----
 thunar/thunar-private.h           |   17 -----------------
 thunar/thunar-renamer-model.c     |    4 ++--
 thunar/thunar-renamer-pair.c      |    4 ++--
 thunar/thunar-shortcuts-model.c   |   16 ++++++++--------
 thunar/thunar-thumbnailer.c       |   12 ++++++------
 thunar/thunar-transfer-job.c      |    6 +++---
 thunar/thunar-tree-model.c        |    6 +++---
 thunar/thunar-tree-view.c         |    4 ++--
 12 files changed, 38 insertions(+), 55 deletions(-)

diff --git a/thunar/thunar-browser.c b/thunar/thunar-browser.c
index e9e08fd..197d646 100644
--- a/thunar/thunar-browser.c
+++ b/thunar/thunar-browser.c
@@ -93,7 +93,7 @@ thunar_browser_poke_file_data_new (ThunarBrowser            *browser,
   _thunar_return_val_if_fail (THUNAR_IS_FILE (source), NULL);
   _thunar_return_val_if_fail (THUNAR_IS_FILE (file), NULL);
 
-  poke_data = _thunar_slice_new0 (PokeFileData);
+  poke_data = g_slice_new0 (PokeFileData);
   poke_data->browser = g_object_ref (browser);
   poke_data->source = g_object_ref (source);
   poke_data->file = g_object_ref (file);
@@ -117,7 +117,7 @@ thunar_browser_poke_file_data_free (PokeFileData *poke_data)
   g_object_unref (poke_data->source);
   g_object_unref (poke_data->file);
 
-  _thunar_slice_free (PokeFileData, poke_data);
+  g_slice_free (PokeFileData, poke_data);
 }
 
 
@@ -133,7 +133,7 @@ thunar_browser_poke_volume_data_new (ThunarBrowser              *browser,
   _thunar_return_val_if_fail (THUNAR_IS_BROWSER (browser), NULL);
   _thunar_return_val_if_fail (G_IS_VOLUME (volume), NULL);
 
-  poke_data = _thunar_slice_new0 (PokeVolumeData);
+  poke_data = g_slice_new0 (PokeVolumeData);
   poke_data->browser = g_object_ref (browser);
   poke_data->volume = g_object_ref (volume);
   poke_data->func = func;
@@ -154,7 +154,7 @@ thunar_browser_poke_volume_data_free (PokeVolumeData *poke_data)
   g_object_unref (poke_data->browser);
   g_object_unref (poke_data->volume);
 
-  _thunar_slice_free (PokeVolumeData, poke_data);
+  g_slice_free (PokeVolumeData, poke_data);
 }
 
 
diff --git a/thunar/thunar-clipboard-manager.c b/thunar/thunar-clipboard-manager.c
index ee91391..fa40b99 100644
--- a/thunar/thunar-clipboard-manager.c
+++ b/thunar/thunar-clipboard-manager.c
@@ -335,7 +335,7 @@ thunar_clipboard_manager_contents_received (GtkClipboard     *clipboard,
     g_closure_unref (request->new_files_closure);
   g_object_unref (G_OBJECT (request->manager));
   g_object_unref (request->target_file);
-  _thunar_slice_free (ThunarClipboardPasteRequest, request);
+  g_slice_free (ThunarClipboardPasteRequest, request);
 }
 
 
@@ -643,7 +643,7 @@ thunar_clipboard_manager_paste_files (ThunarClipboardManager *manager,
   _thunar_return_if_fail (widget == NULL || GTK_IS_WIDGET (widget));
 
   /* prepare the paste request */
-  request = _thunar_slice_new0 (ThunarClipboardPasteRequest);
+  request = g_slice_new0 (ThunarClipboardPasteRequest);
   request->manager = g_object_ref (G_OBJECT (manager));
   request->target_file = g_object_ref (target_file);
   request->widget = widget;
diff --git a/thunar/thunar-exec.c b/thunar/thunar-exec.c
index f2f5a40..e4a2358 100644
--- a/thunar/thunar-exec.c
+++ b/thunar/thunar-exec.c
@@ -305,7 +305,7 @@ tvsn_startup_timeout_destroy (gpointer data)
                           NULL, NULL);
 
   /* release the startup data */
-  _thunar_slice_free (TsnStartupData, startup_data);
+  g_slice_free (TsnStartupData, startup_data);
 }
 
 static void
@@ -484,7 +484,7 @@ thunar_exec_on_screen (GdkScreen   *screen,
       else
         {
           /* schedule a startup notification timeout */
-          startup_data = _thunar_slice_new (TsnStartupData);
+          startup_data = g_slice_new (TsnStartupData);
           startup_data->sn_launcher = sn_launcher;
           startup_data->timeout_id = g_timeout_add_full (G_PRIORITY_LOW, TSN_STARTUP_TIMEOUT, tvsn_startup_timeout,
                                                          startup_data, tvsn_startup_timeout_destroy);
diff --git a/thunar/thunar-launcher.c b/thunar/thunar-launcher.c
index 8482060..4c2279d 100644
--- a/thunar/thunar-launcher.c
+++ b/thunar/thunar-launcher.c
@@ -1270,7 +1270,7 @@ thunar_launcher_mount_data_new (ThunarLauncher *launcher,
 
   _thunar_return_val_if_fail (THUNAR_IS_LAUNCHER (launcher), NULL);
 
-  data = _thunar_slice_new0 (ThunarLauncherMountData);
+  data = g_slice_new0 (ThunarLauncherMountData);
   data->launcher = g_object_ref (launcher);
   data->files = thunar_g_file_list_copy (files);
 
@@ -1287,7 +1287,7 @@ thunar_launcher_mount_data_free (ThunarLauncherMountData *data)
 
   g_object_unref (data->launcher);
   thunar_g_file_list_free (data->files);
-  _thunar_slice_free (ThunarLauncherMountData, data);
+  g_slice_free (ThunarLauncherMountData, data);
 }
 
 
@@ -1297,7 +1297,7 @@ thunar_launcher_poke_data_new (GList *files)
 {
   ThunarLauncherPokeData *data;
 
-  data = _thunar_slice_new0 (ThunarLauncherPokeData);
+  data = g_slice_new0 (ThunarLauncherPokeData);
   data->files = thunar_file_list_copy (files);
   data->resolved_files = NULL;
 
@@ -1313,7 +1313,7 @@ thunar_launcher_poke_data_free (ThunarLauncherPokeData *data)
 
   thunar_file_list_free (data->files);
   thunar_file_list_free (data->resolved_files);
-  _thunar_slice_free (ThunarLauncherPokeData, data);
+  g_slice_free (ThunarLauncherPokeData, data);
 }
 
 
diff --git a/thunar/thunar-private.h b/thunar/thunar-private.h
index 5411eae..a6f8f7b 100644
--- a/thunar/thunar-private.h
+++ b/thunar/thunar-private.h
@@ -38,23 +38,6 @@ G_BEGIN_DECLS;
 #define _thunar_return_val_if_fail(expr, val) G_STMT_START{ (void)0; }G_STMT_END
 #endif
 
-/* support macros for the slice allocator */
-#if GLIB_CHECK_VERSION(2,10,0)
-#define _thunar_slice_alloc(block_size)             (g_slice_alloc ((block_size)))
-#define _thunar_slice_alloc0(block_size)            (g_slice_alloc0 ((block_size)))
-#define _thunar_slice_free1(block_size, mem_block)  G_STMT_START{ g_slice_free1 ((block_size), (mem_block)); }G_STMT_END
-#define _thunar_slice_new(type)                     (g_slice_new (type))
-#define _thunar_slice_new0(type)                    (g_slice_new0 (type))
-#define _thunar_slice_free(type, ptr)               G_STMT_START{ g_slice_free (type, (ptr)); }G_STMT_END
-#else
-#define _thunar_slice_alloc(block_size)             (g_malloc ((block_size)))
-#define _thunar_slice_alloc0(block_size)            (g_malloc0 ((block_size)))
-#define _thunar_slice_free1(block_size, mem_block)  G_STMT_START{ g_free ((mem_block)); }G_STMT_END
-#define _thunar_slice_new(type)                     (g_new (type, 1))
-#define _thunar_slice_new0(type)                    (g_new0 (type, 1))
-#define _thunar_slice_free(type, ptr)               G_STMT_START{ g_free ((ptr)); }G_STMT_END
-#endif
-
 /* avoid trivial g_value_get_*() function calls */
 #ifdef NDEBUG
 #define g_value_get_boolean(v)  (((const GValue *) (v))->data[0].v_int)
diff --git a/thunar/thunar-renamer-model.c b/thunar/thunar-renamer-model.c
index 7024dca..05e7900 100644
--- a/thunar/thunar-renamer-model.c
+++ b/thunar/thunar-renamer-model.c
@@ -956,7 +956,7 @@ thunar_renamer_model_item_new (ThunarFile *file)
 {
   ThunarRenamerModelItem *item;
 
-  item = _thunar_slice_new0 (ThunarRenamerModelItem);
+  item = g_slice_new0 (ThunarRenamerModelItem);
   item->file = g_object_ref (G_OBJECT (file));
   item->dirty = TRUE;
 
@@ -970,7 +970,7 @@ thunar_renamer_model_item_free (ThunarRenamerModelItem *item)
 {
   g_object_unref (G_OBJECT (item->file));
   g_free (item->name);
-  _thunar_slice_free (ThunarRenamerModelItem, item);
+  g_slice_free (ThunarRenamerModelItem, item);
 }
 
 
diff --git a/thunar/thunar-renamer-pair.c b/thunar/thunar-renamer-pair.c
index 4982c1d..544ed28 100644
--- a/thunar/thunar-renamer-pair.c
+++ b/thunar/thunar-renamer-pair.c
@@ -66,7 +66,7 @@ thunar_renamer_pair_new (ThunarFile  *file,
   _thunar_return_val_if_fail (THUNAR_IS_FILE (file), NULL);
   _thunar_return_val_if_fail (g_utf8_validate (name, -1, NULL), NULL);
 
-  renamer_pair = _thunar_slice_new (ThunarRenamerPair);
+  renamer_pair = g_slice_new (ThunarRenamerPair);
   renamer_pair->file = g_object_ref (G_OBJECT (file));
   renamer_pair->name = g_strdup (name);
 
@@ -109,7 +109,7 @@ thunar_renamer_pair_free (ThunarRenamerPair *renamer_pair)
     {
       g_object_unref (G_OBJECT (renamer_pair->file));
       g_free (renamer_pair->name);
-      _thunar_slice_free (ThunarRenamerPair, renamer_pair);
+      g_slice_free (ThunarRenamerPair, renamer_pair);
     }
 }
 
diff --git a/thunar/thunar-shortcuts-model.c b/thunar/thunar-shortcuts-model.c
index 0f458c6..618278c 100644
--- a/thunar/thunar-shortcuts-model.c
+++ b/thunar/thunar-shortcuts-model.c
@@ -267,7 +267,7 @@ thunar_shortcuts_model_init (ThunarShortcutsModel *model)
       if (G_LIKELY (file != NULL))
         {
           /* create the shortcut */
-          shortcut = _thunar_slice_new0 (ThunarShortcut);
+          shortcut = g_slice_new0 (ThunarShortcut);
           shortcut->type = THUNAR_SHORTCUT_SYSTEM_DEFINED;
           shortcut->file = file;
 
@@ -318,7 +318,7 @@ thunar_shortcuts_model_init (ThunarShortcutsModel *model)
           /* generate the shortcut (w/o a file, else we might
            * prevent the volume from being unmounted)
            */
-          shortcut = _thunar_slice_new0 (ThunarShortcut);
+          shortcut = g_slice_new0 (ThunarShortcut);
           shortcut->type = THUNAR_SHORTCUT_REMOVABLE_MEDIA;
           shortcut->volume = volume;
 
@@ -336,7 +336,7 @@ thunar_shortcuts_model_init (ThunarShortcutsModel *model)
   g_list_free (volumes);
 
   /* prepend the row separator */
-  shortcut = _thunar_slice_new0 (ThunarShortcut);
+  shortcut = g_slice_new0 (ThunarShortcut);
   shortcut->type = THUNAR_SHORTCUT_SEPARATOR;
   thunar_shortcuts_model_add_shortcut (model, shortcut, path);
   gtk_tree_path_next (path);
@@ -839,7 +839,7 @@ thunar_shortcuts_model_load (ThunarShortcutsModel *model)
           if (G_UNLIKELY (thunar_file_is_directory (file)))
             {
               /* create the shortcut entry */
-              shortcut = _thunar_slice_new0 (ThunarShortcut);
+              shortcut = g_slice_new0 (ThunarShortcut);
               shortcut->type = THUNAR_SHORTCUT_USER_DEFINED;
               shortcut->file = file;
               shortcut->name = (*name != '\0') ? g_strdup (name) : NULL;
@@ -918,7 +918,7 @@ thunar_shortcuts_model_load (ThunarShortcutsModel *model)
             }
 
           /* create the shortcut entry */
-          shortcut = _thunar_slice_new0 (ThunarShortcut);
+          shortcut = g_slice_new0 (ThunarShortcut);
           shortcut->type = THUNAR_SHORTCUT_USER_DEFINED;
           shortcut->file = file;
           shortcut->name = g_strdup (dgettext (XDG_USER_DIRS_PACKAGE, 
@@ -1159,7 +1159,7 @@ thunar_shortcuts_model_volume_changed (GVolumeMonitor       *volume_monitor,
             }
 
           /* allocate a new shortcut */
-          shortcut = _thunar_slice_new0 (ThunarShortcut);
+          shortcut = g_slice_new0 (ThunarShortcut);
           shortcut->type = THUNAR_SHORTCUT_REMOVABLE_MEDIA;
           shortcut->volume = volume;
 
@@ -1293,7 +1293,7 @@ thunar_shortcut_free (ThunarShortcut       *shortcut,
   g_free (shortcut->name);
 
   /* release the shortcut itself */
-  _thunar_slice_free (ThunarShortcut, shortcut);
+  g_slice_free (ThunarShortcut, shortcut);
 }
 
 
@@ -1455,7 +1455,7 @@ thunar_shortcuts_model_add (ThunarShortcutsModel *model,
       return;
 
   /* create the new shortcut that will be inserted */
-  shortcut = _thunar_slice_new0 (ThunarShortcut);
+  shortcut = g_slice_new0 (ThunarShortcut);
   shortcut->type = THUNAR_SHORTCUT_USER_DEFINED;
   shortcut->file = g_object_ref (G_OBJECT (file));
 
diff --git a/thunar/thunar-thumbnailer.c b/thunar/thunar-thumbnailer.c
index ae651a0..bdd9822 100644
--- a/thunar/thunar-thumbnailer.c
+++ b/thunar/thunar-thumbnailer.c
@@ -477,7 +477,7 @@ thunar_thumbnailer_thumbnailer_error (DBusGProxy        *proxy,
   if (request != NULL)
     {
       /* allocate a new idle struct */
-      idle = _thunar_slice_new0 (ThunarThumbnailerIdle);
+      idle = g_slice_new0 (ThunarThumbnailerIdle);
       idle->type = THUNAR_THUMBNAILER_IDLE_ERROR;
       idle->thumbnailer = g_object_ref (thumbnailer);
 
@@ -536,7 +536,7 @@ thunar_thumbnailer_thumbnailer_ready (DBusGProxy        *proxy,
   if (uris != NULL)
     {
       /* allocate a new idle struct */
-      idle = _thunar_slice_new0 (ThunarThumbnailerIdle);
+      idle = g_slice_new0 (ThunarThumbnailerIdle);
       idle->type = THUNAR_THUMBNAILER_IDLE_READY;
       idle->thumbnailer = g_object_ref (thumbnailer);
 
@@ -574,7 +574,7 @@ thunar_thumbnailer_thumbnailer_started (DBusGProxy        *proxy,
   if (request != NULL)
     {
       /* allocate a new idle struct */
-      idle = _thunar_slice_new0 (ThunarThumbnailerIdle);
+      idle = g_slice_new0 (ThunarThumbnailerIdle);
       idle->type = THUNAR_THUMBNAILER_IDLE_STARTED;
       idle->thumbnailer = g_object_ref (thumbnailer);
 
@@ -665,7 +665,7 @@ thunar_thumbnailer_queue_async (ThunarThumbnailer *thumbnailer,
   request = thumbnailer->last_request;
 
   /* allocate a new call struct for the async D-Bus call */
-  thumbnailer_call = _thunar_slice_new0 (ThunarThumbnailerCall);
+  thumbnailer_call = g_slice_new0 (ThunarThumbnailerCall);
   thumbnailer_call->request = request;
   thumbnailer_call->thumbnailer = g_object_ref (thumbnailer);
 
@@ -902,7 +902,7 @@ thunar_thumbnailer_call_free (ThunarThumbnailerCall *call)
   g_object_unref (call->thumbnailer);
 
   /* free the struct */
-  _thunar_slice_free (ThunarThumbnailerCall, call);
+  g_slice_free (ThunarThumbnailerCall, call);
 }
 
 
@@ -925,7 +925,7 @@ thunar_thumbnailer_idle_free (gpointer data)
   g_object_unref (idle->thumbnailer);
 
   /* free the struct */
-  _thunar_slice_free (ThunarThumbnailerIdle, idle);
+  g_slice_free (ThunarThumbnailerIdle, idle);
 }
 #endif /* HAVE_DBUS */
 
diff --git a/thunar/thunar-transfer-job.c b/thunar/thunar-transfer-job.c
index f661229..7dc187d 100644
--- a/thunar/thunar-transfer-job.c
+++ b/thunar/thunar-transfer-job.c
@@ -185,7 +185,7 @@ thunar_transfer_job_collect_node (ThunarTransferJob  *job,
       for (lp = file_list; err == NULL && lp != NULL; lp = lp->next)
         {
           /* allocate a new transfer node for the child */
-          child_node = _thunar_slice_new0 (ThunarTransferNode);
+          child_node = g_slice_new0 (ThunarTransferNode);
           child_node->source_file = g_object_ref (lp->data);
 
           /* hook the child node into the child list */
@@ -806,7 +806,7 @@ thunar_transfer_node_free (ThunarTransferNode *node)
       g_object_unref (node->source_file);
 
       /* release the resources of this node */
-      _thunar_slice_free (ThunarTransferNode, node);
+      g_slice_free (ThunarTransferNode, node);
 
       /* continue with the next node */
       node = next;
@@ -845,7 +845,7 @@ thunar_transfer_job_new (GList                *source_node_list,
       if (G_LIKELY (type != THUNAR_TRANSFER_JOB_MOVE || !g_file_equal (sp->data, tp->data)))
         {
           /* append transfer node for this source file */
-          node = _thunar_slice_new0 (ThunarTransferNode);
+          node = g_slice_new0 (ThunarTransferNode);
           node->source_file = g_object_ref (sp->data);
           job->source_node_list = g_list_append (job->source_node_list, node);
 
diff --git a/thunar/thunar-tree-model.c b/thunar/thunar-tree-model.c
index b6d9a29..c1e5069 100644
--- a/thunar/thunar-tree-model.c
+++ b/thunar/thunar-tree-model.c
@@ -1164,7 +1164,7 @@ thunar_tree_model_item_new_with_file (ThunarTreeModel *model,
 {
   ThunarTreeModelItem *item;
 
-  item = _thunar_slice_new0 (ThunarTreeModelItem);
+  item = g_slice_new0 (ThunarTreeModelItem);
   item->file = g_object_ref (G_OBJECT (file));
   item->model = model;
 
@@ -1181,7 +1181,7 @@ thunar_tree_model_item_new_with_volume (ThunarTreeModel *model,
   GMount              *mount;
   GFile               *mount_point;
 
-  item = _thunar_slice_new0 (ThunarTreeModelItem);
+  item = g_slice_new0 (ThunarTreeModelItem);
   item->volume = g_object_ref (G_OBJECT (volume));
   item->model = model;
 
@@ -1218,7 +1218,7 @@ thunar_tree_model_item_free (ThunarTreeModelItem *item)
   thunar_tree_model_item_reset (item);
 
   /* release the item */
-  _thunar_slice_free (ThunarTreeModelItem, item);
+  g_slice_free (ThunarTreeModelItem, item);
 }
 
 
diff --git a/thunar/thunar-tree-view.c b/thunar/thunar-tree-view.c
index 8b71bc4..cdbaa9d 100644
--- a/thunar/thunar-tree-view.c
+++ b/thunar/thunar-tree-view.c
@@ -2405,7 +2405,7 @@ thunar_tree_view_mount_data_new (ThunarTreeView *view,
 {
   ThunarTreeViewMountData *data;
 
-  data = _thunar_slice_new0 (ThunarTreeViewMountData);
+  data = g_slice_new0 (ThunarTreeViewMountData);
   data->path = path == NULL ? NULL : gtk_tree_path_copy (path);
   data->view = g_object_ref (view);
   data->open_after_mounting = open_after_mounting;
@@ -2424,7 +2424,7 @@ thunar_tree_view_mount_data_free (ThunarTreeViewMountData *data)
   if (data->path != NULL)
     gtk_tree_path_free (data->path);
   g_object_unref (data->view);
-  _thunar_slice_free (ThunarTreeViewMountData, data);
+  g_slice_free (ThunarTreeViewMountData, data);
 }
 
 



More information about the Xfce4-commits mailing list