mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 23:16:14 +01:00
Allow NULL clear function when releasing references
Both g_rc_box_release_full() and g_atomic_rc_box_release_full() should allow passing NULL as the clear function, to conform to the existing coding practices in GLib. Additionally, this allows us to reimplement release() in terms of release_full(), and improve test coverage.
This commit is contained in:
parent
68304ae583
commit
7c4ac58938
@ -307,15 +307,7 @@ gpointer
|
||||
void
|
||||
g_atomic_rc_box_release (gpointer mem_block)
|
||||
{
|
||||
GArcBox *real_box = G_ARC_BOX (mem_block);
|
||||
|
||||
g_return_if_fail (mem_block != NULL);
|
||||
#ifndef G_DISABLE_ASSERT
|
||||
g_return_if_fail (real_box->magic == G_BOX_MAGIC);
|
||||
#endif
|
||||
|
||||
if (g_atomic_ref_count_dec (&real_box->ref_count))
|
||||
g_free (real_box);
|
||||
g_atomic_rc_box_release_full (mem_block, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -338,13 +330,13 @@ g_atomic_rc_box_release_full (gpointer mem_block,
|
||||
GArcBox *real_box = G_ARC_BOX (mem_block);
|
||||
|
||||
g_return_if_fail (mem_block != NULL);
|
||||
g_return_if_fail (clear_func != NULL);
|
||||
#ifndef G_DISABLE_ASSERT
|
||||
g_return_if_fail (real_box->magic == G_BOX_MAGIC);
|
||||
#endif
|
||||
|
||||
if (g_atomic_ref_count_dec (&real_box->ref_count))
|
||||
{
|
||||
if (clear_func != NULL)
|
||||
clear_func (mem_block);
|
||||
g_free (real_box);
|
||||
}
|
||||
|
@ -377,15 +377,7 @@ gpointer
|
||||
void
|
||||
g_rc_box_release (gpointer mem_block)
|
||||
{
|
||||
GRcBox *real_box = G_RC_BOX (mem_block);
|
||||
|
||||
g_return_if_fail (mem_block != NULL);
|
||||
#ifndef G_DISABLE_ASSERT
|
||||
g_return_if_fail (real_box->magic == G_BOX_MAGIC);
|
||||
#endif
|
||||
|
||||
if (g_ref_count_dec (&real_box->ref_count))
|
||||
g_free (real_box);
|
||||
g_rc_box_release_full (mem_block, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -408,13 +400,13 @@ g_rc_box_release_full (gpointer mem_block,
|
||||
GRcBox *real_box = G_RC_BOX (mem_block);
|
||||
|
||||
g_return_if_fail (mem_block != NULL);
|
||||
g_return_if_fail (clear_func != NULL);
|
||||
#ifndef G_DISABLE_ASSERT
|
||||
g_return_if_fail (real_box->magic == G_BOX_MAGIC);
|
||||
#endif
|
||||
|
||||
if (g_ref_count_dec (&real_box->ref_count))
|
||||
{
|
||||
if (clear_func != NULL)
|
||||
clear_func (mem_block);
|
||||
g_free (real_box);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user