/* Returns: the data element, or NULL if it is not found.  */
gpointer g_datalist_get_data(GData **datalist, const gchar *key)
/* Returns: the data element, or NULL if it is not found.  */
gpointer g_datalist_get_data(GData **datalist, const gchar *key)
{
  gpointer res = NULL;
  GData *d;
  GDataElt *data, *data_end;
  g_return_val_if_fail (datalist != NULL, NULL);
  g_datalist_lock (datalist);
  d = G_DATALIST_GET_POINTER (datalist);
  if (d)
    {
      data = d->data;
      data_end = data + d->len;
      while (data < data_end)
	{
	  if (g_strcmp0 (g_quark_to_string (data->key), key) == 0)
	    {
	      res = data->data;
	      break;
	    }
	  data++;
	}
    }
  g_datalist_unlock (datalist);
  return res;
}