mirror of
https://github.com/ostreedev/ostree.git
synced 2025-03-19 22:50:35 +03:00
core: Increase type safety of some local alloc functions
This commit is contained in:
parent
19571c7652
commit
ff3867c052
@ -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);
|
||||
}
|
||||
|
@ -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)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user