From bbb532d59ca7a65cb4e879877b193b66dd539a2c Mon Sep 17 00:00:00 2001 From: Tim Janik Date: Thu, 3 Feb 2000 20:43:00 +0000 Subject: [PATCH] return stolen data from g_datalist_id_remove_no_notify() and Fri Feb 4 19:36:05 2000 Tim Janik * glib.h: * gdataset.c: return stolen data from g_datalist_id_remove_no_notify() and g_dataset_id_remove_no_notify() to avoid second lookup for common use. --- ChangeLog | 7 +++++++ ChangeLog.pre-2-0 | 7 +++++++ ChangeLog.pre-2-10 | 7 +++++++ ChangeLog.pre-2-12 | 7 +++++++ ChangeLog.pre-2-2 | 7 +++++++ ChangeLog.pre-2-4 | 7 +++++++ ChangeLog.pre-2-6 | 7 +++++++ ChangeLog.pre-2-8 | 7 +++++++ gdataset.c | 34 ++++++++++++++++++++++++---------- glib.h | 4 ++-- glib/gdataset.c | 34 ++++++++++++++++++++++++---------- glib/glib.h | 4 ++-- 12 files changed, 108 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index cb3d8709..33499607 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Fri Feb 4 19:36:05 2000 Tim Janik + + * glib.h: + * gdataset.c: return stolen data from g_datalist_id_remove_no_notify() + and g_dataset_id_remove_no_notify() to avoid second lookup for common + use. + 2000-02-01 Tor Lillqvist * glib.h diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index cb3d8709..33499607 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,10 @@ +Fri Feb 4 19:36:05 2000 Tim Janik + + * glib.h: + * gdataset.c: return stolen data from g_datalist_id_remove_no_notify() + and g_dataset_id_remove_no_notify() to avoid second lookup for common + use. + 2000-02-01 Tor Lillqvist * glib.h diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index cb3d8709..33499607 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,10 @@ +Fri Feb 4 19:36:05 2000 Tim Janik + + * glib.h: + * gdataset.c: return stolen data from g_datalist_id_remove_no_notify() + and g_dataset_id_remove_no_notify() to avoid second lookup for common + use. + 2000-02-01 Tor Lillqvist * glib.h diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index cb3d8709..33499607 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,10 @@ +Fri Feb 4 19:36:05 2000 Tim Janik + + * glib.h: + * gdataset.c: return stolen data from g_datalist_id_remove_no_notify() + and g_dataset_id_remove_no_notify() to avoid second lookup for common + use. + 2000-02-01 Tor Lillqvist * glib.h diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index cb3d8709..33499607 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,10 @@ +Fri Feb 4 19:36:05 2000 Tim Janik + + * glib.h: + * gdataset.c: return stolen data from g_datalist_id_remove_no_notify() + and g_dataset_id_remove_no_notify() to avoid second lookup for common + use. + 2000-02-01 Tor Lillqvist * glib.h diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index cb3d8709..33499607 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,10 @@ +Fri Feb 4 19:36:05 2000 Tim Janik + + * glib.h: + * gdataset.c: return stolen data from g_datalist_id_remove_no_notify() + and g_dataset_id_remove_no_notify() to avoid second lookup for common + use. + 2000-02-01 Tor Lillqvist * glib.h diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index cb3d8709..33499607 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,10 @@ +Fri Feb 4 19:36:05 2000 Tim Janik + + * glib.h: + * gdataset.c: return stolen data from g_datalist_id_remove_no_notify() + and g_dataset_id_remove_no_notify() to avoid second lookup for common + use. + 2000-02-01 Tor Lillqvist * glib.h diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index cb3d8709..33499607 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,10 @@ +Fri Feb 4 19:36:05 2000 Tim Janik + + * glib.h: + * gdataset.c: return stolen data from g_datalist_id_remove_no_notify() + and g_dataset_id_remove_no_notify() to avoid second lookup for common + use. + 2000-02-01 Tor Lillqvist * glib.h diff --git a/gdataset.c b/gdataset.c index 2aa4032a..e9530165 100644 --- a/gdataset.c +++ b/gdataset.c @@ -64,7 +64,7 @@ struct _GDataset static inline GDataset* g_dataset_lookup (gconstpointer dataset_location); static inline void g_datalist_clear_i (GData **datalist); static void g_dataset_destroy_internal (GDataset *dataset); -static inline void g_data_set_internal (GData **datalist, +static inline gpointer g_data_set_internal (GData **datalist, GQuark key_id, gpointer data, GDestroyNotify destroy_func, @@ -198,7 +198,7 @@ g_dataset_destroy (gconstpointer dataset_location) } /* HOLDS: g_dataset_global_lock */ -static inline void +static inline gpointer g_data_set_internal (GData **datalist, GQuark key_id, gpointer data, @@ -217,6 +217,8 @@ g_data_set_internal (GData **datalist, { if (list->id == key_id) { + gpointer ret_data = NULL; + if (prev) prev->next = list->next; else @@ -242,6 +244,8 @@ g_data_set_internal (GData **datalist, list->destroy_func (list->data); G_LOCK (g_dataset_global); } + else + ret_data = list->data; if (g_data_cache_length < G_DATA_CACHE_MAX) { @@ -252,7 +256,7 @@ g_data_set_internal (GData **datalist, else g_mem_chunk_free (g_data_mem_chunk, list); - return; + return ret_data; } prev = list; @@ -288,7 +292,7 @@ g_data_set_internal (GData **datalist, G_LOCK (g_dataset_global); } - return; + return NULL; } list = list->next; @@ -308,6 +312,8 @@ g_data_set_internal (GData **datalist, list->destroy_func = destroy_func; *datalist = list; } + + return NULL; } void @@ -373,11 +379,13 @@ g_datalist_id_set_data_full (GData **datalist, G_UNLOCK (g_dataset_global); } -void +gpointer g_dataset_id_remove_no_notify (gconstpointer dataset_location, GQuark key_id) { - g_return_if_fail (dataset_location != NULL); + gpointer ret_data = NULL; + + g_return_val_if_fail (dataset_location != NULL, NULL); G_LOCK (g_dataset_global); if (key_id && g_dataset_location_ht) @@ -386,21 +394,27 @@ g_dataset_id_remove_no_notify (gconstpointer dataset_location, dataset = g_dataset_lookup (dataset_location); if (dataset) - g_data_set_internal (&dataset->datalist, key_id, NULL, (GDestroyNotify) 42, dataset); + ret_data = g_data_set_internal (&dataset->datalist, key_id, NULL, (GDestroyNotify) 42, dataset); } G_UNLOCK (g_dataset_global); + + return ret_data; } -void +gpointer g_datalist_id_remove_no_notify (GData **datalist, GQuark key_id) { - g_return_if_fail (datalist != NULL); + gpointer ret_data = NULL; + + g_return_val_if_fail (datalist != NULL, NULL); G_LOCK (g_dataset_global); if (key_id && g_dataset_location_ht) - g_data_set_internal (datalist, key_id, NULL, (GDestroyNotify) 42, NULL); + ret_data = g_data_set_internal (datalist, key_id, NULL, (GDestroyNotify) 42, NULL); G_UNLOCK (g_dataset_global); + + return ret_data; } gpointer diff --git a/glib.h b/glib.h index 0a6d646e..84c4170b 100644 --- a/glib.h +++ b/glib.h @@ -1971,7 +1971,7 @@ void g_datalist_id_set_data_full (GData **datalist, GQuark key_id, gpointer data, GDestroyNotify destroy_func); -void g_datalist_id_remove_no_notify (GData **datalist, +gpointer g_datalist_id_remove_no_notify (GData **datalist, GQuark key_id); void g_datalist_foreach (GData **datalist, GDataForeachFunc func, @@ -2001,7 +2001,7 @@ void g_dataset_id_set_data_full (gconstpointer dataset_location, GQuark key_id, gpointer data, GDestroyNotify destroy_func); -void g_dataset_id_remove_no_notify (gconstpointer dataset_location, +gpointer g_dataset_id_remove_no_notify (gconstpointer dataset_location, GQuark key_id); void g_dataset_foreach (gconstpointer dataset_location, GDataForeachFunc func, diff --git a/glib/gdataset.c b/glib/gdataset.c index 2aa4032a..e9530165 100644 --- a/glib/gdataset.c +++ b/glib/gdataset.c @@ -64,7 +64,7 @@ struct _GDataset static inline GDataset* g_dataset_lookup (gconstpointer dataset_location); static inline void g_datalist_clear_i (GData **datalist); static void g_dataset_destroy_internal (GDataset *dataset); -static inline void g_data_set_internal (GData **datalist, +static inline gpointer g_data_set_internal (GData **datalist, GQuark key_id, gpointer data, GDestroyNotify destroy_func, @@ -198,7 +198,7 @@ g_dataset_destroy (gconstpointer dataset_location) } /* HOLDS: g_dataset_global_lock */ -static inline void +static inline gpointer g_data_set_internal (GData **datalist, GQuark key_id, gpointer data, @@ -217,6 +217,8 @@ g_data_set_internal (GData **datalist, { if (list->id == key_id) { + gpointer ret_data = NULL; + if (prev) prev->next = list->next; else @@ -242,6 +244,8 @@ g_data_set_internal (GData **datalist, list->destroy_func (list->data); G_LOCK (g_dataset_global); } + else + ret_data = list->data; if (g_data_cache_length < G_DATA_CACHE_MAX) { @@ -252,7 +256,7 @@ g_data_set_internal (GData **datalist, else g_mem_chunk_free (g_data_mem_chunk, list); - return; + return ret_data; } prev = list; @@ -288,7 +292,7 @@ g_data_set_internal (GData **datalist, G_LOCK (g_dataset_global); } - return; + return NULL; } list = list->next; @@ -308,6 +312,8 @@ g_data_set_internal (GData **datalist, list->destroy_func = destroy_func; *datalist = list; } + + return NULL; } void @@ -373,11 +379,13 @@ g_datalist_id_set_data_full (GData **datalist, G_UNLOCK (g_dataset_global); } -void +gpointer g_dataset_id_remove_no_notify (gconstpointer dataset_location, GQuark key_id) { - g_return_if_fail (dataset_location != NULL); + gpointer ret_data = NULL; + + g_return_val_if_fail (dataset_location != NULL, NULL); G_LOCK (g_dataset_global); if (key_id && g_dataset_location_ht) @@ -386,21 +394,27 @@ g_dataset_id_remove_no_notify (gconstpointer dataset_location, dataset = g_dataset_lookup (dataset_location); if (dataset) - g_data_set_internal (&dataset->datalist, key_id, NULL, (GDestroyNotify) 42, dataset); + ret_data = g_data_set_internal (&dataset->datalist, key_id, NULL, (GDestroyNotify) 42, dataset); } G_UNLOCK (g_dataset_global); + + return ret_data; } -void +gpointer g_datalist_id_remove_no_notify (GData **datalist, GQuark key_id) { - g_return_if_fail (datalist != NULL); + gpointer ret_data = NULL; + + g_return_val_if_fail (datalist != NULL, NULL); G_LOCK (g_dataset_global); if (key_id && g_dataset_location_ht) - g_data_set_internal (datalist, key_id, NULL, (GDestroyNotify) 42, NULL); + ret_data = g_data_set_internal (datalist, key_id, NULL, (GDestroyNotify) 42, NULL); G_UNLOCK (g_dataset_global); + + return ret_data; } gpointer diff --git a/glib/glib.h b/glib/glib.h index 0a6d646e..84c4170b 100644 --- a/glib/glib.h +++ b/glib/glib.h @@ -1971,7 +1971,7 @@ void g_datalist_id_set_data_full (GData **datalist, GQuark key_id, gpointer data, GDestroyNotify destroy_func); -void g_datalist_id_remove_no_notify (GData **datalist, +gpointer g_datalist_id_remove_no_notify (GData **datalist, GQuark key_id); void g_datalist_foreach (GData **datalist, GDataForeachFunc func, @@ -2001,7 +2001,7 @@ void g_dataset_id_set_data_full (gconstpointer dataset_location, GQuark key_id, gpointer data, GDestroyNotify destroy_func); -void g_dataset_id_remove_no_notify (gconstpointer dataset_location, +gpointer g_dataset_id_remove_no_notify (gconstpointer dataset_location, GQuark key_id); void g_dataset_foreach (gconstpointer dataset_location, GDataForeachFunc func, -- 2.34.1