[libgsystem] localalloc: Rename macros



commit 56d727341706c82742c5427bef35cdde00c3713a
Author: Colin Walters <walters verbum org>
Date:   Mon Dec 3 11:59:12 2012 -0500

    localalloc: Rename macros
    
    These are a bit clearer, if more verbose.  For example, it's now more
    obvious with "gs_unref_object" that an unref is going to happen.
    
    Based on discussion with Pavel Simerda <psimerda redhat com>.

 gsystem-file-utils.c  |    4 ++--
 gsystem-local-alloc.c |    9 +++++----
 gsystem-local-alloc.h |   24 ++++++++++++------------
 gsystem-shutil.c      |   14 +++++++-------
 4 files changed, 26 insertions(+), 25 deletions(-)
---
diff --git a/gsystem-file-utils.c b/gsystem-file-utils.c
index 555f968..b436923 100644
--- a/gsystem-file-utils.c
+++ b/gsystem-file-utils.c
@@ -64,7 +64,7 @@ gs_file_read_noatime (GFile         *file,
                       GCancellable  *cancellable,
                       GError       **error)
 {
-  gs_lfree char *path = NULL;
+  gs_free char *path = NULL;
   int fd;
 
   if (g_cancellable_set_error_if_cancelled (cancellable, error))
@@ -256,7 +256,7 @@ gs_file_ensure_directory (GFile         *dir,
       if (with_parents &&
           g_error_matches (temp_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
         {
-          gs_lobj GFile *parent = NULL;
+          gs_unref_object GFile *parent = NULL;
 
           g_clear_error (&temp_error);
 
diff --git a/gsystem-local-alloc.c b/gsystem-local-alloc.c
index 0059896..243f7ac 100644
--- a/gsystem-local-alloc.c
+++ b/gsystem-local-alloc.c
@@ -33,9 +33,10 @@
  * url="http://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html";>
  * for more information on the attribute.
  *
- * The provided macros make it easy to use the cleanup attribute for types
- * that come with GLib.  The primary two are #gs_lfree and #gs_lobj,
- * which correspond to g_free() and g_object_unref(), respectively.
+ * The provided macros make it easy to use the cleanup attribute for
+ * types that come with GLib.  The primary two are #gs_free and
+ * #gs_unref_object, which correspond to g_free() and
+ * g_object_unref(), respectively.
  *
  * The rationale behind this is that particularly when handling error
  * paths, it can be very tricky to ensure the right variables are
@@ -55,7 +56,7 @@
  * GFile *
  * create_file (GError **error)
  * {
- *   gs_lfree char *random_id = NULL;
+ *   gs_free char *random_id = NULL;
  *
  *   if (!prepare_file (error))
  *     return NULL;
diff --git a/gsystem-local-alloc.h b/gsystem-local-alloc.h
index 9471293..a44c4d4 100644
--- a/gsystem-local-alloc.h
+++ b/gsystem-local-alloc.h
@@ -38,56 +38,56 @@ void gs_local_ptrarray_unref (void *loc);
 void gs_local_hashtable_unref (void *loc);
 
 /**
- * gs_lfree:
+ * gs_free:
  *
  * Call g_free() on a variable location when it goes out of scope.
  */
-#define gs_lfree __attribute__ ((cleanup(gs_local_free)))
+#define gs_free __attribute__ ((cleanup(gs_local_free)))
 
 /**
- * gs_lobj:
+ * gs_unref_object:
  *
  * Call g_object_unref() on a variable location when it goes out of
  * scope.  Note that unlike g_object_unref(), the variable may be
  * %NULL.
  */
-#define gs_lobj __attribute__ ((cleanup(gs_local_obj_unref)))
+#define gs_unref_object __attribute__ ((cleanup(gs_local_obj_unref)))
 
 /**
- * gs_lvariant:
+ * gs_unref_variant:
  *
  * Call g_variant_unref() on a variable location when it goes out of
  * scope.  Note that unlike g_variant_unref(), the variable may be
  * %NULL.
  */
-#define gs_lvariant __attribute__ ((cleanup(gs_local_variant_unref)))
+#define gs_unref_variant __attribute__ ((cleanup(gs_local_variant_unref)))
 
 /**
- * gs_lvariant_iter:
+ * gs_free_variant_iter:
  *
  * Call g_variant_iter_free() on a variable location when it goes out of
  * scope.
  */
-#define gs_lvariant_iter __attribute__ ((cleanup(gs_local_variant_iter_free)))
+#define gs_free_variant_iter __attribute__ ((cleanup(gs_local_variant_iter_free)))
 
 /**
- * gs_lptrarray:
+ * gs_unref_ptrarray:
  *
  * Call g_ptr_array_unref() on a variable location when it goes out of
  * scope.  Note that unlike g_ptr_array_unref(), the variable may be
  * %NULL.
 
  */
-#define gs_lptrarray __attribute__ ((cleanup(gs_local_ptrarray_unref)))
+#define gs_unref_ptrarray __attribute__ ((cleanup(gs_local_ptrarray_unref)))
 
 /**
- * gs_lhash:
+ * gs_unref_hashtable:
  *
  * Call g_hash_table_unref() on a variable location when it goes out
  * of scope.  Note that unlike g_hash_table_unref(), the variable may
  * be %NULL.
  */
-#define gs_lhash __attribute__ ((cleanup(gs_local_hashtable_unref)))
+#define gs_unref_hashtable __attribute__ ((cleanup(gs_local_hashtable_unref)))
 
 G_END_DECLS
 
diff --git a/gsystem-shutil.c b/gsystem-shutil.c
index d38d7b4..428f851 100644
--- a/gsystem-shutil.c
+++ b/gsystem-shutil.c
@@ -37,8 +37,8 @@ cp_internal (GFile         *src,
              GError       **error)
 {
   gboolean ret = FALSE;
-  gs_lobj GFileEnumerator *enumerator = NULL;
-  gs_lobj GFileInfo *file_info = NULL;
+  gs_unref_object GFileEnumerator *enumerator = NULL;
+  gs_unref_object GFileInfo *file_info = NULL;
   GError *temp_error = NULL;
 
   enumerator = g_file_enumerate_children (src, "standard::type,standard::name,unix::mode",
@@ -53,8 +53,8 @@ cp_internal (GFile         *src,
   while ((file_info = g_file_enumerator_next_file (enumerator, cancellable, &temp_error)) != NULL)
     {
       const char *name = g_file_info_get_name (file_info);
-      gs_lobj GFile *src_child = g_file_get_child (src, name);
-      gs_lobj GFile *dest_child = g_file_get_child (dest, name);
+      gs_unref_object GFile *src_child = g_file_get_child (src, name);
+      gs_unref_object GFile *dest_child = g_file_get_child (dest, name);
 
       if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_DIRECTORY)
         {
@@ -180,8 +180,8 @@ gs_shutil_rm_rf (GFile        *path,
                  GError      **error)
 {
   gboolean ret = FALSE;
-  gs_lobj GFileEnumerator *dir_enum = NULL;
-  gs_lobj GFileInfo *file_info = NULL;
+  gs_unref_object GFileEnumerator *dir_enum = NULL;
+  gs_unref_object GFileInfo *file_info = NULL;
   GError *temp_error = NULL;
 
   dir_enum = g_file_enumerate_children (path, "standard::type,standard::name", 
@@ -202,7 +202,7 @@ gs_shutil_rm_rf (GFile        *path,
 
   while ((file_info = g_file_enumerator_next_file (dir_enum, cancellable, &temp_error)) != NULL)
     {
-      gs_lobj GFile *subpath = NULL;
+      gs_unref_object GFile *subpath = NULL;
       GFileType type;
       const char *name;
 



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