diff options
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | ChangeLog.pre-2-0 | 12 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 12 | ||||
-rw-r--r-- | ChangeLog.pre-2-12 | 12 | ||||
-rw-r--r-- | ChangeLog.pre-2-2 | 12 | ||||
-rw-r--r-- | ChangeLog.pre-2-4 | 12 | ||||
-rw-r--r-- | ChangeLog.pre-2-6 | 12 | ||||
-rw-r--r-- | ChangeLog.pre-2-8 | 12 | ||||
-rw-r--r-- | ghash.c | 32 | ||||
-rw-r--r-- | glib.h | 3 | ||||
-rw-r--r-- | glib/ghash.c | 32 | ||||
-rw-r--r-- | glib/glib.h | 3 |
12 files changed, 148 insertions, 18 deletions
@@ -1,3 +1,15 @@ +Tue Nov 24 14:05:47 EST 1998 Michael K. Johnson <johnsonm@redhat.com> + + * glib.h: added GFreeFunc and g_hash_table_set_key_freefunc() + prototype. + * ghash.c: added g_hash_table_set_key_freefunc() implementation. + Modified the prototypes of the functions g_hash_node_destroy() and + g_hash_nodes_destroy(), and changed the functions that call them + to match the new definitions. + This changes no external interfaces, and should create no binary + or source incompatibilities. It does add a member to the + GHashTable structure. + Tue Nov 24 09:40:00 1998 Tim Janik <timj@gtk.org> * glib.h: removed the GListAllocator type and its g_*_allocator_*() diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 4d0a13fc7..30ad0256f 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,15 @@ +Tue Nov 24 14:05:47 EST 1998 Michael K. Johnson <johnsonm@redhat.com> + + * glib.h: added GFreeFunc and g_hash_table_set_key_freefunc() + prototype. + * ghash.c: added g_hash_table_set_key_freefunc() implementation. + Modified the prototypes of the functions g_hash_node_destroy() and + g_hash_nodes_destroy(), and changed the functions that call them + to match the new definitions. + This changes no external interfaces, and should create no binary + or source incompatibilities. It does add a member to the + GHashTable structure. + Tue Nov 24 09:40:00 1998 Tim Janik <timj@gtk.org> * glib.h: removed the GListAllocator type and its g_*_allocator_*() diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 4d0a13fc7..30ad0256f 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,15 @@ +Tue Nov 24 14:05:47 EST 1998 Michael K. Johnson <johnsonm@redhat.com> + + * glib.h: added GFreeFunc and g_hash_table_set_key_freefunc() + prototype. + * ghash.c: added g_hash_table_set_key_freefunc() implementation. + Modified the prototypes of the functions g_hash_node_destroy() and + g_hash_nodes_destroy(), and changed the functions that call them + to match the new definitions. + This changes no external interfaces, and should create no binary + or source incompatibilities. It does add a member to the + GHashTable structure. + Tue Nov 24 09:40:00 1998 Tim Janik <timj@gtk.org> * glib.h: removed the GListAllocator type and its g_*_allocator_*() diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 4d0a13fc7..30ad0256f 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,15 @@ +Tue Nov 24 14:05:47 EST 1998 Michael K. Johnson <johnsonm@redhat.com> + + * glib.h: added GFreeFunc and g_hash_table_set_key_freefunc() + prototype. + * ghash.c: added g_hash_table_set_key_freefunc() implementation. + Modified the prototypes of the functions g_hash_node_destroy() and + g_hash_nodes_destroy(), and changed the functions that call them + to match the new definitions. + This changes no external interfaces, and should create no binary + or source incompatibilities. It does add a member to the + GHashTable structure. + Tue Nov 24 09:40:00 1998 Tim Janik <timj@gtk.org> * glib.h: removed the GListAllocator type and its g_*_allocator_*() diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 4d0a13fc7..30ad0256f 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,15 @@ +Tue Nov 24 14:05:47 EST 1998 Michael K. Johnson <johnsonm@redhat.com> + + * glib.h: added GFreeFunc and g_hash_table_set_key_freefunc() + prototype. + * ghash.c: added g_hash_table_set_key_freefunc() implementation. + Modified the prototypes of the functions g_hash_node_destroy() and + g_hash_nodes_destroy(), and changed the functions that call them + to match the new definitions. + This changes no external interfaces, and should create no binary + or source incompatibilities. It does add a member to the + GHashTable structure. + Tue Nov 24 09:40:00 1998 Tim Janik <timj@gtk.org> * glib.h: removed the GListAllocator type and its g_*_allocator_*() diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 4d0a13fc7..30ad0256f 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,15 @@ +Tue Nov 24 14:05:47 EST 1998 Michael K. Johnson <johnsonm@redhat.com> + + * glib.h: added GFreeFunc and g_hash_table_set_key_freefunc() + prototype. + * ghash.c: added g_hash_table_set_key_freefunc() implementation. + Modified the prototypes of the functions g_hash_node_destroy() and + g_hash_nodes_destroy(), and changed the functions that call them + to match the new definitions. + This changes no external interfaces, and should create no binary + or source incompatibilities. It does add a member to the + GHashTable structure. + Tue Nov 24 09:40:00 1998 Tim Janik <timj@gtk.org> * glib.h: removed the GListAllocator type and its g_*_allocator_*() diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 4d0a13fc7..30ad0256f 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,15 @@ +Tue Nov 24 14:05:47 EST 1998 Michael K. Johnson <johnsonm@redhat.com> + + * glib.h: added GFreeFunc and g_hash_table_set_key_freefunc() + prototype. + * ghash.c: added g_hash_table_set_key_freefunc() implementation. + Modified the prototypes of the functions g_hash_node_destroy() and + g_hash_nodes_destroy(), and changed the functions that call them + to match the new definitions. + This changes no external interfaces, and should create no binary + or source incompatibilities. It does add a member to the + GHashTable structure. + Tue Nov 24 09:40:00 1998 Tim Janik <timj@gtk.org> * glib.h: removed the GListAllocator type and its g_*_allocator_*() diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 4d0a13fc7..30ad0256f 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,15 @@ +Tue Nov 24 14:05:47 EST 1998 Michael K. Johnson <johnsonm@redhat.com> + + * glib.h: added GFreeFunc and g_hash_table_set_key_freefunc() + prototype. + * ghash.c: added g_hash_table_set_key_freefunc() implementation. + Modified the prototypes of the functions g_hash_node_destroy() and + g_hash_nodes_destroy(), and changed the functions that call them + to match the new definitions. + This changes no external interfaces, and should create no binary + or source incompatibilities. It does add a member to the + GHashTable structure. + Tue Nov 24 09:40:00 1998 Tim Janik <timj@gtk.org> * glib.h: removed the GListAllocator type and its g_*_allocator_*() @@ -40,6 +40,7 @@ struct _GHashTable GHashNode **nodes; GHashFunc hash_func; GCompareFunc key_compare_func; + GFreeFunc *free_func; }; @@ -48,8 +49,10 @@ static GHashNode** g_hash_table_lookup_node (GHashTable *hash_table, gconstpointer key); static GHashNode* g_hash_node_new (gpointer key, gpointer value); -static void g_hash_node_destroy (GHashNode *hash_node); -static void g_hash_nodes_destroy (GHashNode *hash_node); +static void g_hash_node_destroy (GHashNode *hash_node, + GFreeFunc *free_func); +static void g_hash_nodes_destroy (GHashNode *hash_node, + GFreeFunc *free_func); static GMemChunk *node_mem_chunk = NULL; @@ -70,6 +73,7 @@ g_hash_table_new (GHashFunc hash_func, hash_table->hash_func = hash_func ? hash_func : g_direct_hash; hash_table->key_compare_func = key_compare_func; hash_table->nodes = g_new (GHashNode*, hash_table->size); + hash_table->free_func = NULL; for (i = 0; i < hash_table->size; i++) hash_table->nodes[i] = NULL; @@ -85,7 +89,7 @@ g_hash_table_destroy (GHashTable *hash_table) g_return_if_fail (hash_table != NULL); for (i = 0; i < hash_table->size; i++) - g_hash_nodes_destroy (hash_table->nodes[i]); + g_hash_nodes_destroy (hash_table->nodes[i], hash_table->free_func); g_free (hash_table->nodes); g_free (hash_table); @@ -170,7 +174,7 @@ g_hash_table_remove (GHashTable *hash_table, { dest = *node; (*node) = dest->next; - g_hash_node_destroy (dest); + g_hash_node_destroy (dest, hash_table->free_func); hash_table->nnodes--; } @@ -249,13 +253,13 @@ g_hash_table_foreach_remove (GHashTable *hash_table, if (prev) { prev->next = node->next; - g_hash_node_destroy (node); + g_hash_node_destroy (node, hash_table->free_func); node = prev; } else { hash_table->nodes[i] = node->next; - g_hash_node_destroy (node); + g_hash_node_destroy (node, hash_table->free_func); goto restart; } } @@ -293,6 +297,12 @@ g_hash_table_size (GHashTable *hash_table) return hash_table->nnodes; } +void +g_hash_table_set_key_freefunc (GHashTable *hash_table, GFreeFunc *free_func) +{ + hash_table->free_func = free_func; +} + static void g_hash_table_resize (GHashTable *hash_table) { @@ -361,14 +371,15 @@ g_hash_node_new (gpointer key, } static void -g_hash_node_destroy (GHashNode *hash_node) +g_hash_node_destroy (GHashNode *hash_node, GFreeFunc *free_func) { + if (free_func) (*free_func)(hash_node->key); hash_node->next = node_free_list; node_free_list = hash_node; } static void -g_hash_nodes_destroy (GHashNode *hash_node) +g_hash_nodes_destroy (GHashNode *hash_node, GFreeFunc *free_func) { GHashNode *node; @@ -378,7 +389,10 @@ g_hash_nodes_destroy (GHashNode *hash_node) node = hash_node; while (node->next) - node = node->next; + { + if (free_func) (*free_func)(node->key); + node = node->next; + } node->next = node_free_list; node_free_list = hash_node; @@ -779,6 +779,7 @@ typedef void (*GDataForeachFunc) (GQuark key_id, typedef void (*GFunc) (gpointer data, gpointer user_data); typedef guint (*GHashFunc) (gconstpointer key); +typedef void (*GFreeFunc) (gpointer data); typedef void (*GHFunc) (gpointer key, gpointer value, gpointer user_data); @@ -986,6 +987,8 @@ gint g_hash_table_foreach_remove (GHashTable *hash_table, GHRFunc func, gpointer user_data); gint g_hash_table_size (GHashTable *hash_table); +void g_hash_table_set_key_freefunc (GHashTable *hash_table, + GFreeFunc *free_func); /* Caches diff --git a/glib/ghash.c b/glib/ghash.c index 0ff5a2415..6fa142b11 100644 --- a/glib/ghash.c +++ b/glib/ghash.c @@ -40,6 +40,7 @@ struct _GHashTable GHashNode **nodes; GHashFunc hash_func; GCompareFunc key_compare_func; + GFreeFunc *free_func; }; @@ -48,8 +49,10 @@ static GHashNode** g_hash_table_lookup_node (GHashTable *hash_table, gconstpointer key); static GHashNode* g_hash_node_new (gpointer key, gpointer value); -static void g_hash_node_destroy (GHashNode *hash_node); -static void g_hash_nodes_destroy (GHashNode *hash_node); +static void g_hash_node_destroy (GHashNode *hash_node, + GFreeFunc *free_func); +static void g_hash_nodes_destroy (GHashNode *hash_node, + GFreeFunc *free_func); static GMemChunk *node_mem_chunk = NULL; @@ -70,6 +73,7 @@ g_hash_table_new (GHashFunc hash_func, hash_table->hash_func = hash_func ? hash_func : g_direct_hash; hash_table->key_compare_func = key_compare_func; hash_table->nodes = g_new (GHashNode*, hash_table->size); + hash_table->free_func = NULL; for (i = 0; i < hash_table->size; i++) hash_table->nodes[i] = NULL; @@ -85,7 +89,7 @@ g_hash_table_destroy (GHashTable *hash_table) g_return_if_fail (hash_table != NULL); for (i = 0; i < hash_table->size; i++) - g_hash_nodes_destroy (hash_table->nodes[i]); + g_hash_nodes_destroy (hash_table->nodes[i], hash_table->free_func); g_free (hash_table->nodes); g_free (hash_table); @@ -170,7 +174,7 @@ g_hash_table_remove (GHashTable *hash_table, { dest = *node; (*node) = dest->next; - g_hash_node_destroy (dest); + g_hash_node_destroy (dest, hash_table->free_func); hash_table->nnodes--; } @@ -249,13 +253,13 @@ g_hash_table_foreach_remove (GHashTable *hash_table, if (prev) { prev->next = node->next; - g_hash_node_destroy (node); + g_hash_node_destroy (node, hash_table->free_func); node = prev; } else { hash_table->nodes[i] = node->next; - g_hash_node_destroy (node); + g_hash_node_destroy (node, hash_table->free_func); goto restart; } } @@ -293,6 +297,12 @@ g_hash_table_size (GHashTable *hash_table) return hash_table->nnodes; } +void +g_hash_table_set_key_freefunc (GHashTable *hash_table, GFreeFunc *free_func) +{ + hash_table->free_func = free_func; +} + static void g_hash_table_resize (GHashTable *hash_table) { @@ -361,14 +371,15 @@ g_hash_node_new (gpointer key, } static void -g_hash_node_destroy (GHashNode *hash_node) +g_hash_node_destroy (GHashNode *hash_node, GFreeFunc *free_func) { + if (free_func) (*free_func)(hash_node->key); hash_node->next = node_free_list; node_free_list = hash_node; } static void -g_hash_nodes_destroy (GHashNode *hash_node) +g_hash_nodes_destroy (GHashNode *hash_node, GFreeFunc *free_func) { GHashNode *node; @@ -378,7 +389,10 @@ g_hash_nodes_destroy (GHashNode *hash_node) node = hash_node; while (node->next) - node = node->next; + { + if (free_func) (*free_func)(node->key); + node = node->next; + } node->next = node_free_list; node_free_list = hash_node; diff --git a/glib/glib.h b/glib/glib.h index 0442020f3..8ebb2afaa 100644 --- a/glib/glib.h +++ b/glib/glib.h @@ -779,6 +779,7 @@ typedef void (*GDataForeachFunc) (GQuark key_id, typedef void (*GFunc) (gpointer data, gpointer user_data); typedef guint (*GHashFunc) (gconstpointer key); +typedef void (*GFreeFunc) (gpointer data); typedef void (*GHFunc) (gpointer key, gpointer value, gpointer user_data); @@ -986,6 +987,8 @@ gint g_hash_table_foreach_remove (GHashTable *hash_table, GHRFunc func, gpointer user_data); gint g_hash_table_size (GHashTable *hash_table); +void g_hash_table_set_key_freefunc (GHashTable *hash_table, + GFreeFunc *free_func); /* Caches |