d3ae9ae8ed0d33af5fa5c63d87f270eaafcf4139
[platform/upstream/glib.git] / glib / ghash.c
1 /* GLIB - Library of useful routines for C programming
2  * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 /*
21  * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
22  * file for a list of people on the GLib Team.  See the ChangeLog
23  * files for a list of changes.  These files are distributed with
24  * GLib at ftp://ftp.gtk.org/pub/gtk/. 
25  */
26
27 /* 
28  * MT safe
29  */
30
31 #include "config.h"
32
33 #include "glib.h"
34 #include "galias.h"
35
36
37 #define HASH_TABLE_MIN_SIZE 11
38 #define HASH_TABLE_MAX_SIZE 13845163
39
40
41 typedef struct _GHashNode      GHashNode;
42
43 struct _GHashNode
44 {
45   gpointer   key;
46   gpointer   value;
47   GHashNode *next;
48 };
49
50 struct _GHashTable
51 {
52   gint             size;
53   gint             nnodes;
54   GHashNode      **nodes;
55   GHashFunc        hash_func;
56   GEqualFunc       key_equal_func;
57   GDestroyNotify   key_destroy_func;
58   GDestroyNotify   value_destroy_func;
59 };
60
61 #define G_HASH_TABLE_RESIZE(hash_table)                         \
62    G_STMT_START {                                               \
63      if ((hash_table->size >= 3 * hash_table->nnodes &&         \
64           hash_table->size > HASH_TABLE_MIN_SIZE) ||            \
65          (3 * hash_table->size <= hash_table->nnodes &&         \
66           hash_table->size < HASH_TABLE_MAX_SIZE))              \
67            g_hash_table_resize (hash_table);                    \
68    } G_STMT_END
69
70 static void             g_hash_table_resize       (GHashTable     *hash_table);
71 static GHashNode**      g_hash_table_lookup_node  (GHashTable     *hash_table,
72                                                    gconstpointer   key);
73 static GHashNode*       g_hash_node_new           (gpointer        key,
74                                                    gpointer        value);
75 static void             g_hash_node_destroy       (GHashNode      *hash_node,
76                                                    GDestroyNotify  key_destroy_func,
77                                                    GDestroyNotify  value_destroy_func);
78 static void             g_hash_nodes_destroy      (GHashNode      *hash_node,
79                                                   GDestroyNotify   key_destroy_func,
80                                                   GDestroyNotify   value_destroy_func);
81 static guint g_hash_table_foreach_remove_or_steal (GHashTable     *hash_table,
82                                                    GHRFunc         func,
83                                                    gpointer        user_data,
84                                                    gboolean        notify);
85
86
87 #ifndef DISABLE_MEM_POOLS
88 G_LOCK_DEFINE_STATIC (g_hash_global);
89
90 static GMemChunk *node_mem_chunk = NULL;
91 static GHashNode *node_free_list = NULL;
92 #endif
93
94 /**
95  * g_hash_table_new:
96  * @hash_func: a function to create a hash value from a key.
97  *   Hash values are used to determine where keys are stored within the
98  *   #GHashTable data structure. The g_direct_hash(), g_int_hash() and 
99  *   g_str_hash() functions are provided for some common types of keys. 
100  *   If hash_func is %NULL, g_direct_hash() is used.
101  * @key_equal_func: a function to check two keys for equality.  This is
102  *   used when looking up keys in the #GHashTable.  The g_direct_equal(),
103  *   g_int_equal() and g_str_equal() functions are provided for the most
104  *   common types of keys. If @key_equal_func is %NULL, keys are compared
105  *   directly in a similar fashion to g_direct_equal(), but without the
106  *   overhead of a function call.
107  *
108  * Creates a new #GHashTable.
109  * 
110  * Return value: a new #GHashTable.
111  **/
112 GHashTable*
113 g_hash_table_new (GHashFunc    hash_func,
114                   GEqualFunc   key_equal_func)
115 {
116   return g_hash_table_new_full (hash_func, key_equal_func, NULL, NULL);
117 }
118
119
120 /**
121  * g_hash_table_new_full:
122  * @hash_func: a function to create a hash value from a key.
123  * @key_equal_func: a function to check two keys for equality.
124  * @key_destroy_func: a function to free the memory allocated for the key 
125  *   used when removing the entry from the #GHashTable or %NULL if you 
126  *   don't want to supply such a function.
127  * @value_destroy_func: a function to free the memory allocated for the 
128  *   value used when removing the entry from the #GHashTable or %NULL if 
129  *   you don't want to supply such a function.
130  * 
131  * Creates a new #GHashTable like g_hash_table_new() and allows to specify
132  * functions to free the memory allocated for the key and value that get 
133  * called when removing the entry from the #GHashTable.
134  * 
135  * Return value: a new #GHashTable.
136  **/
137 GHashTable*
138 g_hash_table_new_full (GHashFunc       hash_func,
139                        GEqualFunc      key_equal_func,
140                        GDestroyNotify  key_destroy_func,
141                        GDestroyNotify  value_destroy_func)
142 {
143   GHashTable *hash_table;
144   guint i;
145   
146   hash_table = g_new (GHashTable, 1);
147   hash_table->size               = HASH_TABLE_MIN_SIZE;
148   hash_table->nnodes             = 0;
149   hash_table->hash_func          = hash_func ? hash_func : g_direct_hash;
150   hash_table->key_equal_func     = key_equal_func;
151   hash_table->key_destroy_func   = key_destroy_func;
152   hash_table->value_destroy_func = value_destroy_func;
153   hash_table->nodes              = g_new (GHashNode*, hash_table->size);
154   
155   for (i = 0; i < hash_table->size; i++)
156     hash_table->nodes[i] = NULL;
157   
158   return hash_table;
159 }
160
161 /**
162  * g_hash_table_destroy:
163  * @hash_table: a #GHashTable.
164  * 
165  * Destroys the #GHashTable. If keys and/or values are dynamically 
166  * allocated, you should either free them first or create the #GHashTable
167  * using g_hash_table_new_full(). In the latter case the destroy functions 
168  * you supplied will be called on all keys and values before destroying 
169  * the #GHashTable.
170  **/
171 void
172 g_hash_table_destroy (GHashTable *hash_table)
173 {
174   guint i;
175   
176   g_return_if_fail (hash_table != NULL);
177   
178   for (i = 0; i < hash_table->size; i++)
179     g_hash_nodes_destroy (hash_table->nodes[i], 
180                           hash_table->key_destroy_func,
181                           hash_table->value_destroy_func);
182   
183   g_free (hash_table->nodes);
184   g_free (hash_table);
185 }
186
187 static inline GHashNode**
188 g_hash_table_lookup_node (GHashTable    *hash_table,
189                           gconstpointer  key)
190 {
191   GHashNode **node;
192   
193   node = &hash_table->nodes
194     [(* hash_table->hash_func) (key) % hash_table->size];
195   
196   /* Hash table lookup needs to be fast.
197    *  We therefore remove the extra conditional of testing
198    *  whether to call the key_equal_func or not from
199    *  the inner loop.
200    */
201   if (hash_table->key_equal_func)
202     while (*node && !(*hash_table->key_equal_func) ((*node)->key, key))
203       node = &(*node)->next;
204   else
205     while (*node && (*node)->key != key)
206       node = &(*node)->next;
207   
208   return node;
209 }
210
211 /**
212  * g_hash_table_lookup:
213  * @hash_table: a #GHashTable.
214  * @key: the key to look up.
215  * 
216  * Looks up a key in a #GHashTable. Note that this function cannot
217  * distinguish between a key that is not present and one which is present
218  * and has the value %NULL. If you need this distinction, use
219  * g_hash_table_lookup_extended().
220  * 
221  * Return value: the associated value, or %NULL if the key is not found.
222  **/
223 gpointer
224 g_hash_table_lookup (GHashTable   *hash_table,
225                      gconstpointer key)
226 {
227   GHashNode *node;
228   
229   g_return_val_if_fail (hash_table != NULL, NULL);
230   
231   node = *g_hash_table_lookup_node (hash_table, key);
232   
233   return node ? node->value : NULL;
234 }
235
236 /**
237  * g_hash_table_lookup_extended:
238  * @hash_table: a #GHashTable.
239  * @lookup_key: the key to look up.
240  * @orig_key: returns the original key.
241  * @value: returns the value associated with the key.
242  * 
243  * Looks up a key in the #GHashTable, returning the original key and the
244  * associated value and a #gboolean which is %TRUE if the key was found. This 
245  * is useful if you need to free the memory allocated for the original key, 
246  * for example before calling g_hash_table_remove().
247  * 
248  * Return value: %TRUE if the key was found in the #GHashTable.
249  **/
250 gboolean
251 g_hash_table_lookup_extended (GHashTable    *hash_table,
252                               gconstpointer  lookup_key,
253                               gpointer      *orig_key,
254                               gpointer      *value)
255 {
256   GHashNode *node;
257   
258   g_return_val_if_fail (hash_table != NULL, FALSE);
259   
260   node = *g_hash_table_lookup_node (hash_table, lookup_key);
261   
262   if (node)
263     {
264       if (orig_key)
265         *orig_key = node->key;
266       if (value)
267         *value = node->value;
268       return TRUE;
269     }
270   else
271     return FALSE;
272 }
273
274 /**
275  * g_hash_table_insert:
276  * @hash_table: a #GHashTable.
277  * @key: a key to insert.
278  * @value: the value to associate with the key.
279  * 
280  * Inserts a new key and value into a #GHashTable.
281  * 
282  * If the key already exists in the #GHashTable its current value is replaced
283  * with the new value. If you supplied a @value_destroy_func when creating the 
284  * #GHashTable, the old value is freed using that function. If you supplied
285  * a @key_destroy_func when creating the #GHashTable, the passed key is freed 
286  * using that function.
287  **/
288 void
289 g_hash_table_insert (GHashTable *hash_table,
290                      gpointer    key,
291                      gpointer    value)
292 {
293   GHashNode **node;
294   
295   g_return_if_fail (hash_table != NULL);
296   
297   node = g_hash_table_lookup_node (hash_table, key);
298   
299   if (*node)
300     {
301       /* do not reset node->key in this place, keeping
302        * the old key is the intended behaviour. 
303        * g_hash_table_replace() can be used instead.
304        */
305
306       /* free the passed key */
307       if (hash_table->key_destroy_func)
308         hash_table->key_destroy_func (key);
309       
310       if (hash_table->value_destroy_func)
311         hash_table->value_destroy_func ((*node)->value);
312
313       (*node)->value = value;
314     }
315   else
316     {
317       *node = g_hash_node_new (key, value);
318       hash_table->nnodes++;
319       G_HASH_TABLE_RESIZE (hash_table);
320     }
321 }
322
323 /**
324  * g_hash_table_replace:
325  * @hash_table: a #GHashTable.
326  * @key: a key to insert.
327  * @value: the value to associate with the key.
328  * 
329  * Inserts a new key and value into a #GHashTable similar to 
330  * g_hash_table_insert(). The difference is that if the key already exists 
331  * in the #GHashTable, it gets replaced by the new key. If you supplied a 
332  * @value_destroy_func when creating the #GHashTable, the old value is freed 
333  * using that function. If you supplied a @key_destroy_func when creating the 
334  * #GHashTable, the old key is freed using that function. 
335  **/
336 void
337 g_hash_table_replace (GHashTable *hash_table,
338                       gpointer    key,
339                       gpointer    value)
340 {
341   GHashNode **node;
342   
343   g_return_if_fail (hash_table != NULL);
344   
345   node = g_hash_table_lookup_node (hash_table, key);
346   
347   if (*node)
348     {
349       if (hash_table->key_destroy_func)
350         hash_table->key_destroy_func ((*node)->key);
351       
352       if (hash_table->value_destroy_func)
353         hash_table->value_destroy_func ((*node)->value);
354
355       (*node)->key   = key;
356       (*node)->value = value;
357     }
358   else
359     {
360       *node = g_hash_node_new (key, value);
361       hash_table->nnodes++;
362       G_HASH_TABLE_RESIZE (hash_table);
363     }
364 }
365
366 /**
367  * g_hash_table_remove:
368  * @hash_table: a #GHashTable.
369  * @key: the key to remove.
370  * 
371  * Removes a key and its associated value from a #GHashTable.
372  *
373  * If the #GHashTable was created using g_hash_table_new_full(), the
374  * key and value are freed using the supplied destroy functions, otherwise
375  * you have to make sure that any dynamically allocated values are freed 
376  * yourself.
377  * 
378  * Return value: %TRUE if the key was found and removed from the #GHashTable.
379  **/
380 gboolean
381 g_hash_table_remove (GHashTable    *hash_table,
382                      gconstpointer  key)
383 {
384   GHashNode **node, *dest;
385   
386   g_return_val_if_fail (hash_table != NULL, FALSE);
387   
388   node = g_hash_table_lookup_node (hash_table, key);
389   if (*node)
390     {
391       dest = *node;
392       (*node) = dest->next;
393       g_hash_node_destroy (dest, 
394                            hash_table->key_destroy_func,
395                            hash_table->value_destroy_func);
396       hash_table->nnodes--;
397   
398       G_HASH_TABLE_RESIZE (hash_table);
399
400       return TRUE;
401     }
402
403   return FALSE;
404 }
405
406 /**
407  * g_hash_table_steal:
408  * @hash_table: a #GHashTable.
409  * @key: the key to remove.
410  * 
411  * Removes a key and its associated value from a #GHashTable without
412  * calling the key and value destroy functions.
413  *
414  * Return value: %TRUE if the key was found and removed from the #GHashTable.
415  **/
416 gboolean
417 g_hash_table_steal (GHashTable    *hash_table,
418                     gconstpointer  key)
419 {
420   GHashNode **node, *dest;
421   
422   g_return_val_if_fail (hash_table != NULL, FALSE);
423   
424   node = g_hash_table_lookup_node (hash_table, key);
425   if (*node)
426     {
427       dest = *node;
428       (*node) = dest->next;
429       g_hash_node_destroy (dest, NULL, NULL);
430       hash_table->nnodes--;
431   
432       G_HASH_TABLE_RESIZE (hash_table);
433
434       return TRUE;
435     }
436
437   return FALSE;
438 }
439
440 /**
441  * g_hash_table_foreach_remove:
442  * @hash_table: a #GHashTable.
443  * @func: the function to call for each key/value pair.
444  * @user_data: user data to pass to the function.
445  * 
446  * Calls the given function for each key/value pair in the #GHashTable.
447  * If the function returns %TRUE, then the key/value pair is removed from the
448  * #GHashTable. If you supplied key or value destroy functions when creating
449  * the #GHashTable, they are used to free the memory allocated for the removed
450  * keys and values.
451  * 
452  * Return value: the number of key/value pairs removed.
453  **/
454 guint
455 g_hash_table_foreach_remove (GHashTable *hash_table,
456                              GHRFunc     func,
457                              gpointer    user_data)
458 {
459   g_return_val_if_fail (hash_table != NULL, 0);
460   g_return_val_if_fail (func != NULL, 0);
461   
462   return g_hash_table_foreach_remove_or_steal (hash_table, func, user_data, TRUE);
463 }
464
465 /**
466  * g_hash_table_foreach_steal:
467  * @hash_table: a #GHashTable.
468  * @func: the function to call for each key/value pair.
469  * @user_data: user data to pass to the function.
470  * 
471  * Calls the given function for each key/value pair in the #GHashTable.
472  * If the function returns %TRUE, then the key/value pair is removed from the
473  * #GHashTable, but no key or value destroy functions are called.
474  * 
475  * Return value: the number of key/value pairs removed.
476  **/
477 guint
478 g_hash_table_foreach_steal (GHashTable *hash_table,
479                             GHRFunc     func,
480                             gpointer    user_data)
481 {
482   g_return_val_if_fail (hash_table != NULL, 0);
483   g_return_val_if_fail (func != NULL, 0);
484   
485   return g_hash_table_foreach_remove_or_steal (hash_table, func, user_data, FALSE);
486 }
487
488 static guint
489 g_hash_table_foreach_remove_or_steal (GHashTable *hash_table,
490                                       GHRFunc     func,
491                                       gpointer    user_data,
492                                       gboolean    notify)
493 {
494   GHashNode *node, *prev;
495   guint i;
496   guint deleted = 0;
497   
498   for (i = 0; i < hash_table->size; i++)
499     {
500     restart:
501       
502       prev = NULL;
503       
504       for (node = hash_table->nodes[i]; node; prev = node, node = node->next)
505         {
506           if ((* func) (node->key, node->value, user_data))
507             {
508               deleted += 1;
509               
510               hash_table->nnodes -= 1;
511               
512               if (prev)
513                 {
514                   prev->next = node->next;
515                   g_hash_node_destroy (node,
516                                        notify ? hash_table->key_destroy_func : NULL,
517                                        notify ? hash_table->value_destroy_func : NULL);
518                   node = prev;
519                 }
520               else
521                 {
522                   hash_table->nodes[i] = node->next;
523                   g_hash_node_destroy (node,
524                                        notify ? hash_table->key_destroy_func : NULL,
525                                        notify ? hash_table->value_destroy_func : NULL);
526                   goto restart;
527                 }
528             }
529         }
530     }
531   
532   G_HASH_TABLE_RESIZE (hash_table);
533   
534   return deleted;
535 }
536
537 /**
538  * g_hash_table_foreach:
539  * @hash_table: a #GHashTable.
540  * @func: the function to call for each key/value pair.
541  * @user_data: user data to pass to the function.
542  * 
543  * Calls the given function for each of the key/value pairs in the
544  * #GHashTable.  The function is passed the key and value of each
545  * pair, and the given @user_data parameter.  The hash table may not
546  * be modified while iterating over it (you can't add/remove
547  * items). To remove all items matching a predicate, use
548  * g_hash_table_foreach_remove().
549  **/
550 void
551 g_hash_table_foreach (GHashTable *hash_table,
552                       GHFunc      func,
553                       gpointer    user_data)
554 {
555   GHashNode *node;
556   gint i;
557   
558   g_return_if_fail (hash_table != NULL);
559   g_return_if_fail (func != NULL);
560   
561   for (i = 0; i < hash_table->size; i++)
562     for (node = hash_table->nodes[i]; node; node = node->next)
563       (* func) (node->key, node->value, user_data);
564 }
565
566 /**
567  * g_hash_table_find:
568  * @hash_table: a #GHashTable.
569  * @predicate:  function to test the key/value pairs for a certain property.
570  * @user_data:  user data to pass to the function.
571  * 
572  * Calls the given function for key/value pairs in the #GHashTable until 
573  * @predicate returns %TRUE.  The function is passed the key and value of 
574  * each pair, and the given @user_data parameter. The hash table may not
575  * be modified while iterating over it (you can't add/remove items). 
576  *
577  * Return value: The value of the first key/value pair is returned, for which 
578  * func evaluates to %TRUE. If no pair with the requested property is found, 
579  * %NULL is returned.
580  *
581  * Since: 2.4
582  **/
583 gpointer
584 g_hash_table_find (GHashTable      *hash_table,
585                    GHRFunc          predicate,
586                    gpointer         user_data)
587 {
588   GHashNode *node;
589   gint i;
590   
591   g_return_val_if_fail (hash_table != NULL, NULL);
592   g_return_val_if_fail (predicate != NULL, NULL);
593   
594   for (i = 0; i < hash_table->size; i++)
595     for (node = hash_table->nodes[i]; node; node = node->next)
596       if (predicate (node->key, node->value, user_data))
597         return node->value;       
598   return NULL;
599 }
600
601 /**
602  * g_hash_table_size:
603  * @hash_table: a #GHashTable.
604  * 
605  * Returns the number of elements contained in the #GHashTable.
606  * 
607  * Return value: the number of key/value pairs in the #GHashTable.
608  **/
609 guint
610 g_hash_table_size (GHashTable *hash_table)
611 {
612   g_return_val_if_fail (hash_table != NULL, 0);
613   
614   return hash_table->nnodes;
615 }
616
617 static void
618 g_hash_table_resize (GHashTable *hash_table)
619 {
620   GHashNode **new_nodes;
621   GHashNode *node;
622   GHashNode *next;
623   guint hash_val;
624   gint new_size;
625   gint i;
626
627   new_size = g_spaced_primes_closest (hash_table->nnodes);
628   new_size = CLAMP (new_size, HASH_TABLE_MIN_SIZE, HASH_TABLE_MAX_SIZE);
629  
630   new_nodes = g_new0 (GHashNode*, new_size);
631   
632   for (i = 0; i < hash_table->size; i++)
633     for (node = hash_table->nodes[i]; node; node = next)
634       {
635         next = node->next;
636
637         hash_val = (* hash_table->hash_func) (node->key) % new_size;
638
639         node->next = new_nodes[hash_val];
640         new_nodes[hash_val] = node;
641       }
642   
643   g_free (hash_table->nodes);
644   hash_table->nodes = new_nodes;
645   hash_table->size = new_size;
646 }
647
648 static GHashNode*
649 g_hash_node_new (gpointer key,
650                  gpointer value)
651 {
652   GHashNode *hash_node;
653   
654 #ifdef DISABLE_MEM_POOLS
655   hash_node = g_new (GHashNode, 1);
656 #else
657   G_LOCK (g_hash_global);
658   if (node_free_list)
659     {
660       hash_node = node_free_list;
661       node_free_list = node_free_list->next;
662     }
663   else
664     {
665       if (!node_mem_chunk)
666         node_mem_chunk = g_mem_chunk_new ("hash node mem chunk",
667                                           sizeof (GHashNode),
668                                           1024, G_ALLOC_ONLY);
669       
670       hash_node = g_chunk_new (GHashNode, node_mem_chunk);
671     }
672   G_UNLOCK (g_hash_global);
673 #endif
674   
675   hash_node->key = key;
676   hash_node->value = value;
677   hash_node->next = NULL;
678   
679   return hash_node;
680 }
681
682 static void
683 g_hash_node_destroy (GHashNode      *hash_node,
684                      GDestroyNotify  key_destroy_func,
685                      GDestroyNotify  value_destroy_func)
686 {
687   if (key_destroy_func)
688     key_destroy_func (hash_node->key);
689   if (value_destroy_func)
690     value_destroy_func (hash_node->value);
691   
692 #ifdef ENABLE_GC_FRIENDLY
693   hash_node->key = NULL;
694   hash_node->value = NULL;
695 #endif /* ENABLE_GC_FRIENDLY */
696
697 #ifdef DISABLE_MEM_POOLS
698   g_free (hash_node);
699 #else
700   G_LOCK (g_hash_global);
701   hash_node->next = node_free_list;
702   node_free_list = hash_node;
703   G_UNLOCK (g_hash_global);
704 #endif
705 }
706
707 static void
708 g_hash_nodes_destroy (GHashNode *hash_node,
709                       GFreeFunc  key_destroy_func,
710                       GFreeFunc  value_destroy_func)
711 {
712 #ifdef DISABLE_MEM_POOLS
713   while (hash_node)
714     {
715       GHashNode *next = hash_node->next;
716
717       if (key_destroy_func)
718         key_destroy_func (hash_node->key);
719       if (value_destroy_func)
720         value_destroy_func (hash_node->value);
721
722       g_free (hash_node);
723       hash_node = next;
724     }  
725 #else
726   if (hash_node)
727     {
728       GHashNode *node = hash_node;
729   
730       while (node->next)
731         {
732           if (key_destroy_func)
733             key_destroy_func (node->key);
734           if (value_destroy_func)
735             value_destroy_func (node->value);
736
737 #ifdef ENABLE_GC_FRIENDLY
738           node->key = NULL;
739           node->value = NULL;
740 #endif /* ENABLE_GC_FRIENDLY */
741
742           node = node->next;
743         }
744
745       if (key_destroy_func)
746         key_destroy_func (node->key);
747       if (value_destroy_func)
748         value_destroy_func (node->value);
749
750 #ifdef ENABLE_GC_FRIENDLY
751       node->key = NULL;
752       node->value = NULL;
753 #endif /* ENABLE_GC_FRIENDLY */
754  
755       G_LOCK (g_hash_global);
756       node->next = node_free_list;
757       node_free_list = hash_node;
758       G_UNLOCK (g_hash_global);
759     }
760 #endif
761 }
762
763 #define __G_HASH_C__
764 #include "galiasdef.c"