[ostree] core: Increase type safety of some local alloc functions
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] core: Increase type safety of some local alloc functions
- Date: Thu, 3 May 2012 20:08:13 +0000 (UTC)
commit ff3867c05242f86bf000720058e22046abe1c8d3
Author: Colin Walters <walters verbum org>
Date: Thu May 3 13:26:24 2012 -0400
core: Increase type safety of some local alloc functions
src/libotutil/ot-local-alloc.c | 19 ++++++++++++-------
src/libotutil/ot-local-alloc.h | 6 +++---
2 files changed, 15 insertions(+), 10 deletions(-)
---
diff --git a/src/libotutil/ot-local-alloc.c b/src/libotutil/ot-local-alloc.c
index ab62e0d..cf1dba3 100644
--- a/src/libotutil/ot-local-alloc.c
+++ b/src/libotutil/ot-local-alloc.c
@@ -45,23 +45,28 @@ ot_local_free (void *loc)
void
ot_local_obj_unref (void *loc)
{
- _ot_local_free(GObject, g_object_unref);
+ GObject **location = (GObject**)loc;
+ if (location && *location)
+ g_object_unref (*location);
}
void
-ot_local_variant_unref (void *loc)
+ot_local_variant_unref (GVariant **loc)
{
- _ot_local_free(GVariant, g_variant_unref);
+ if (loc && *loc)
+ g_variant_unref (*loc);
}
void
-ot_local_ptrarray_unref (void *loc)
+ot_local_ptrarray_unref (GPtrArray **loc)
{
- _ot_local_free(GPtrArray, g_ptr_array_unref);
+ if (loc && *loc)
+ g_ptr_array_unref (*loc);
}
void
-ot_local_hashtable_unref (void *loc)
+ot_local_hashtable_unref (GHashTable **loc)
{
- _ot_local_free(GHashTable, g_hash_table_unref);
+ if (loc && *loc)
+ g_hash_table_unref (*loc);
}
diff --git a/src/libotutil/ot-local-alloc.h b/src/libotutil/ot-local-alloc.h
index 2aeea75..3cbfc52 100644
--- a/src/libotutil/ot-local-alloc.h
+++ b/src/libotutil/ot-local-alloc.h
@@ -29,9 +29,9 @@ G_BEGIN_DECLS
void ot_local_free (void *loc);
void ot_local_obj_unref (void *loc);
-void ot_local_variant_unref (void *loc);
-void ot_local_ptrarray_unref (void *loc);
-void ot_local_hashtable_unref (void *loc);
+void ot_local_variant_unref (GVariant **loc);
+void ot_local_ptrarray_unref (GPtrArray **loc);
+void ot_local_hashtable_unref (GHashTable **loc);
#define ot_lfree __attribute__ ((cleanup(ot_local_free)))
#define ot_lobj __attribute__ ((cleanup(ot_local_obj_unref)))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]