/* Frees all the data elements of the datalist. The data elements' destroy functions are called if they have been set.  */
void g_datalist_clear(GData **datalist)
/* Frees all the data elements of the datalist. The data elements' destroy functions are called if they have been set.  */
void g_datalist_clear(GData **datalist)
{
  GData *data;
  gint i;
  g_return_if_fail (datalist != NULL);
  g_datalist_lock (datalist);
  data = G_DATALIST_GET_POINTER (datalist);
  G_DATALIST_SET_POINTER (datalist, NULL);
  g_datalist_unlock (datalist);
  if (data)
    {
      for (i = 0; i < data->len; i++)
        {
          if (data->data[i].data && data->data[i].destroy)
            data->data[i].destroy (data->data[i].data);
        }
      g_free (data);
    }
}