*
* Retrieves the data element corresponding to @key_id.
**/
-/**
- * g_datalist_get_data:
- * @dl: a datalist.
- * @k: the string identifying a data element.
- * @Returns: the data element, or %NULL if it is not found.
- *
- * Gets a data element, using its string identifer. This is slower than
- * g_datalist_id_get_data() because the string is first converted to a
- * #GQuark.
- **/
gpointer
g_datalist_id_get_data (GData **datalist,
GQuark key_id)
return res;
}
+/**
+ * g_datalist_get_data:
+ * @dl: a datalist.
+ * @k: the string identifying a data element.
+ * @Returns: the data element, or %NULL if it is not found.
+ *
+ * Gets a data element, using its string identifer. This is slower than
+ * g_datalist_id_get_data() because it compares strings.
+ **/
+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 (strcmp (g_quark_to_string (data->key), key) == 0)
+ {
+ res = data->data;
+ break;
+ }
+ data++;
+ }
+ }
+
+ g_datalist_unlock (datalist);
+
+ return res;
+}
+
/**
* GDataForeachFunc:
* @key_id: the #GQuark id to identifying the data element.
g_datalist_id_set_data_full ((dl), (q), (d), NULL)
#define g_datalist_id_remove_data(dl, q) \
g_datalist_id_set_data ((dl), (q), NULL)
-#define g_datalist_get_data(dl, k) \
- (g_datalist_id_get_data ((dl), g_quark_try_string (k)))
#define g_datalist_set_data_full(dl, k, d, f) \
g_datalist_id_set_data_full ((dl), g_quark_from_string (k), (d), (f))
#define g_datalist_remove_no_notify(dl, k) \
void g_dataset_destroy (gconstpointer dataset_location);
gpointer g_dataset_id_get_data (gconstpointer dataset_location,
GQuark key_id);
+gpointer g_datalist_get_data (GData **datalist,
+ const gchar *key);
void g_dataset_id_set_data_full (gconstpointer dataset_location,
GQuark key_id,
gpointer data,