[ostree] core: Drop ot_clear_ptrarray in favor of g_clear_pointer



commit 43a2fec6a89babf57ae53aee381f40e42ae54b25
Author: Colin Walters <walters verbum org>
Date:   Tue Jul 17 08:16:54 2012 -0400

    core: Drop ot_clear_ptrarray in favor of g_clear_pointer

 src/libostree/ostree-repo.c      |   14 +++++++-------
 src/libotutil/ot-variant-utils.h |    6 ------
 src/ostree/ostree-pull.c         |    4 ++--
 3 files changed, 9 insertions(+), 15 deletions(-)
---
diff --git a/src/libostree/ostree-repo.c b/src/libostree/ostree-repo.c
index 7590b29..8878113 100644
--- a/src/libostree/ostree-repo.c
+++ b/src/libostree/ostree-repo.c
@@ -116,8 +116,8 @@ ostree_repo_finalize (GObject *object)
     g_hash_table_destroy (self->loose_object_devino_hash);
   if (self->config)
     g_key_file_free (self->config);
-  ot_clear_ptrarray (&self->cached_meta_indexes);
-  ot_clear_ptrarray (&self->cached_content_indexes);
+  g_clear_pointer (&self->cached_meta_indexes, (GDestroyNotify) g_ptr_array_unref);
+  g_clear_pointer (&self->cached_content_indexes, (GDestroyNotify) g_ptr_array_unref);
   g_hash_table_destroy (self->cached_pack_index_mappings);
   g_hash_table_destroy (self->cached_pack_data_mappings);
   g_mutex_clear (&self->cache_lock);
@@ -2025,12 +2025,12 @@ ostree_repo_regenerate_pack_index (OstreeRepo       *self,
   GVariantBuilder *meta_index_content_builder = NULL;
   GVariantBuilder *data_index_content_builder = NULL;
 
-  ot_clear_ptrarray (&self->cached_meta_indexes);
-  ot_clear_ptrarray (&self->cached_content_indexes);
+  g_clear_pointer (&self->cached_meta_indexes, (GDestroyNotify) g_ptr_array_unref);
+  g_clear_pointer (&self->cached_content_indexes, (GDestroyNotify) g_ptr_array_unref);
 
   superindex_path = g_file_get_child (self->pack_dir, "index");
 
-  ot_clear_ptrarray (&pack_indexes);
+  g_clear_pointer (&pack_indexes, (GDestroyNotify) g_ptr_array_unref);
   if (!list_pack_indexes_from_dir (self, TRUE, &pack_indexes,
                                    cancellable, error))
     goto out;
@@ -2039,7 +2039,7 @@ ostree_repo_regenerate_pack_index (OstreeRepo       *self,
                              cancellable, error))
     goto out;
 
-  ot_clear_ptrarray (&pack_indexes);
+  g_clear_pointer (&pack_indexes, (GDestroyNotify) g_ptr_array_unref);
   if (!list_pack_indexes_from_dir (self, FALSE, &pack_indexes,
                                    cancellable, error))
     goto out;
@@ -2366,7 +2366,7 @@ ostree_repo_clean_cached_remote_pack_data (OstreeRepo       *self,
         goto out;
     }
 
-  ot_clear_ptrarray (&data_files);
+  g_clear_pointer (&data_files, (GDestroyNotify) g_ptr_array_unref);
   if (!list_files_in_dir_matching (cache_path,
                                    "ostdatapack-", ".data",
                                    &data_files, 
diff --git a/src/libotutil/ot-variant-utils.h b/src/libotutil/ot-variant-utils.h
index 6ab3dcb..ea238b4 100644
--- a/src/libotutil/ot-variant-utils.h
+++ b/src/libotutil/ot-variant-utils.h
@@ -27,12 +27,6 @@
 
 G_BEGIN_DECLS
 
-#define ot_clear_ptrarray(a_v) do { \
-  if (*a_v)                         \
-    g_ptr_array_unref (*a_v);         \
-  *a_v = NULL;                      \
-  } while (0);
-
 #define ot_clear_hashtable(a_v) do { \
   if (*a_v)                         \
     g_hash_table_unref (*a_v);         \
diff --git a/src/ostree/ostree-pull.c b/src/ostree/ostree-pull.c
index 96c967a..dde4f0a 100644
--- a/src/ostree/ostree-pull.c
+++ b/src/ostree/ostree-pull.c
@@ -1661,8 +1661,8 @@ ostree_builtin_pull (int argc, char **argv, GFile *repo_path, GError **error)
   if (pull_data->base_uri)
     soup_uri_free (pull_data->base_uri);
   ot_clear_hashtable (&pull_data->file_checksums_to_fetch);
-  ot_clear_ptrarray (&pull_data->cached_meta_pack_indexes);
-  ot_clear_ptrarray (&pull_data->cached_data_pack_indexes);
+  g_clear_pointer (&pull_data->cached_meta_pack_indexes, (GDestroyNotify) g_ptr_array_unref);
+  g_clear_pointer (&pull_data->cached_data_pack_indexes, (GDestroyNotify) g_ptr_array_unref);
   if (summary_uri)
     soup_uri_free (summary_uri);
   return ret;



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