/** * g_datalist_clear: * @datalist: a 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) { g_return_if_fail (datalist != NULL); G_LOCK (g_dataset_global); if (!g_dataset_location_ht) g_data_initialize (); while (G_DATALIST_GET_POINTER (datalist)) g_datalist_clear_i (datalist); G_UNLOCK (g_dataset_global); }
/** * g_dataset_remove_data: * @l: the location identifying the dataset. * @k: the string identifying the data element. * * Removes a data element corresponding to a string. Its destroy * function is called if it has been set. **/ void g_dataset_id_set_data_full (gconstpointer dataset_location, GQuark key_id, gpointer data, GDestroyNotify destroy_func) { GDataset *dataset; g_return_if_fail (dataset_location != NULL); if (!data) g_return_if_fail (destroy_func == NULL); if (!key_id) { if (data) g_return_if_fail (key_id > 0); else return; } G_LOCK (g_dataset_global); if (!g_dataset_location_ht) g_data_initialize (); dataset = g_dataset_lookup (dataset_location); if (!dataset) { dataset = g_slice_new (GDataset); #ifdef GSTREAMER_LITE if (dataset == NULL) { G_UNLOCK (g_dataset_global); return; } #endif // GSTREAMER_LITE dataset->location = dataset_location; g_datalist_init (&dataset->datalist); g_hash_table_insert (g_dataset_location_ht, (gpointer) dataset->location, dataset); } g_data_set_internal (&dataset->datalist, key_id, data, destroy_func, dataset); G_UNLOCK (g_dataset_global); }
/** * g_datalist_remove_data: * @dl: a datalist. * @k: the string identifying the data element. * * Removes an element using its string identifier. The data element's * destroy function is called if it has been set. **/ void g_datalist_id_set_data_full (GData **datalist, GQuark key_id, gpointer data, GDestroyNotify destroy_func) { g_return_if_fail (datalist != NULL); if (!data) g_return_if_fail (destroy_func == NULL); if (!key_id) { if (data) g_return_if_fail (key_id > 0); else return; } G_LOCK (g_dataset_global); if (!g_dataset_location_ht) g_data_initialize (); g_data_set_internal (datalist, key_id, data, destroy_func, NULL); G_UNLOCK (g_dataset_global); }