/* Decrements the reference count of a closure after it was previously incremented by the same caller. If no other callers are using the closure, then the closure will be destroyed and freed.  */
void g_closure_unref(GClosure *closure)
/* Decrements the reference count of a closure after it was previously incremented by the same caller. If no other callers are using the closure, then the closure will be destroyed and freed.  */
void g_closure_unref(GClosure *closure)
{
  guint new_ref_count;
  g_return_if_fail (closure != NULL);
  g_return_if_fail (closure->ref_count > 0);
  if (closure->ref_count == 1)
    g_closure_invalidate (closure);
  DEC_ASSIGN (closure, ref_count, &new_ref_count);
  if (new_ref_count == 0)
    {
      closure_invoke_notifiers (closure, FNOTIFY);
      g_free (closure->notifiers);
      if (RUNNING_ON_VALGRIND)
        {
          gchar *allocated;
          allocated = (gchar *) G_REAL_CLOSURE (closure);
          allocated -= sizeof (gpointer);
          g_free (allocated);
          VALGRIND_FREELIKE_BLOCK (allocated + sizeof (gpointer), 0);
          VALGRIND_FREELIKE_BLOCK (closure, 0);
        }
      else
        g_free (G_REAL_CLOSURE (closure));
    }
}