1 /* GLIB - Library of useful routines for C programming
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
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.
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.
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.
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/.
37 #define HASH_TABLE_MIN_SIZE 11
38 #define HASH_TABLE_MAX_SIZE 13845163
41 typedef struct _GHashNode GHashNode;
57 GEqualFunc key_equal_func;
58 volatile gint ref_count;
59 GDestroyNotify key_destroy_func;
60 GDestroyNotify value_destroy_func;
64 * g_hash_table_lookup_node:
65 * @hash_table: our #GHashTable
66 * @key: the key to lookup against
67 * @hash_return: optional key hash return location
68 * Return value: a pointer to the described #GHashNode pointer
70 * Performs a lookup in the hash table. Virtually all hash operations
71 * will use this function internally.
73 * This function first computes the hash value of the key using the
74 * user's hash function.
76 * If an entry in the table matching @key is found then this function
77 * returns a pointer to the pointer to that entry in the table. In
78 * the case that the entry is at the head of a chain, this pointer
79 * will be an item in the nodes[] array. In the case that the entry
80 * is not at the head of a chain, this pointer will be the ->next
81 * pointer on the node that preceeds it.
83 * In the case that no matching entry exists in the table, a pointer
84 * to a %NULL pointer will be returned. To insert a item, this %NULL
85 * pointer should be updated to point to the new #GHashNode.
87 * If @hash_return is a pass-by-reference parameter. If it is
88 * non-%NULL then the computed hash value is returned. This is to
89 * save insertions from having to compute the hash record again for
92 static inline GHashNode **
93 g_hash_table_lookup_node (GHashTable *hash_table,
97 GHashNode **node_ptr, *node;
100 hash_value = (* hash_table->hash_func) (key);
101 node_ptr = &hash_table->nodes[hash_value % hash_table->size];
104 *hash_return = hash_value;
106 /* Hash table lookup needs to be fast.
107 * We therefore remove the extra conditional of testing
108 * whether to call the key_equal_func or not from
111 * Additional optimisation: first check if our full hash
112 * values are equal so we can avoid calling the full-blown
113 * key equality function in most cases.
115 if (hash_table->key_equal_func)
117 while ((node = *node_ptr))
119 if (node->key_hash == hash_value &&
120 hash_table->key_equal_func (node->key, key))
123 node_ptr = &(*node_ptr)->next;
128 while ((node = *node_ptr))
130 if (node->key == key)
133 node_ptr = &(*node_ptr)->next;
141 * g_hash_table_remove_node:
142 * @hash_table: our #GHashTable
143 * @node_ptr_ptr: a pointer to the return value from
144 * g_hash_table_lookup_node()
145 * @notify: %TRUE if the destroy notify handlers are to be called
147 * Removes a node from the hash table and updates the node count. The
148 * node is freed. No table resize is performed.
150 * If @notify is %TRUE then the destroy notify functions are called
151 * for the key and value of the hash node.
153 * @node_ptr_ptr is a pass-by-reference in/out parameter. When the
154 * function is called, it should point to the pointer to the node to
155 * remove. This level of indirection is required so that the pointer
156 * may be updated appropriately once the node has been removed.
158 * Before the function returns, the pointer at @node_ptr_ptr will be
159 * updated to point to the position in the table that contains the
160 * pointer to the "next" node in the chain. This makes this function
161 * convenient to use from functions that iterate over the entire
162 * table. If there is no further item in the chain then the
163 * #GHashNode pointer will be %NULL (ie: **node_ptr_ptr == %NULL).
165 * Since the pointer in the table to the removed node is replaced with
166 * either a pointer to the next node or a %NULL pointer as
167 * appropriate, the pointer at the end of @node_ptr_ptr will never be
168 * modified at all. Stay tuned. :)
171 g_hash_table_remove_node (GHashTable *hash_table,
172 GHashNode ***node_ptr_ptr,
175 GHashNode **node_ptr, *node;
177 node_ptr = *node_ptr_ptr;
180 *node_ptr = node->next;
182 if (notify && hash_table->key_destroy_func)
183 hash_table->key_destroy_func (node->key);
185 if (notify && hash_table->value_destroy_func)
186 hash_table->value_destroy_func (node->value);
188 g_slice_free (GHashNode, node);
190 hash_table->nnodes--;
194 * g_hash_table_remove_all_nodes:
195 * @hash_table: our #GHashTable
196 * @notify: %TRUE if the destroy notify handlers are to be called
198 * Removes all nodes from the table. Since this may be a precursor to
199 * freeing the table entirely, no resize is performed.
201 * If @notify is %TRUE then the destroy notify functions are called
202 * for the key and value of the hash node.
205 g_hash_table_remove_all_nodes (GHashTable *hash_table,
208 GHashNode **node_ptr;
211 for (i = 0; i < hash_table->size; i++)
212 for (node_ptr = &hash_table->nodes[i]; *node_ptr != NULL;)
213 g_hash_table_remove_node (hash_table, &node_ptr, notify);
215 hash_table->nnodes = 0;
219 * g_hash_table_resize:
220 * @hash_table: our #GHashTable
222 * Resizes the hash table to the optimal size based on the number of
223 * nodes currently held. If you call this function then a resize will
224 * occur, even if one does not need to occur. Use
225 * g_hash_table_maybe_resize() instead.
228 g_hash_table_resize (GHashTable *hash_table)
230 GHashNode **new_nodes;
237 new_size = g_spaced_primes_closest (hash_table->nnodes);
238 new_size = CLAMP (new_size, HASH_TABLE_MIN_SIZE, HASH_TABLE_MAX_SIZE);
240 new_nodes = g_new0 (GHashNode*, new_size);
242 for (i = 0; i < hash_table->size; i++)
243 for (node = hash_table->nodes[i]; node; node = next)
247 hash_val = node->key_hash % new_size;
249 node->next = new_nodes[hash_val];
250 new_nodes[hash_val] = node;
253 g_free (hash_table->nodes);
254 hash_table->nodes = new_nodes;
255 hash_table->size = new_size;
259 * g_hash_table_maybe_resize:
260 * @hash_table: our #GHashTable
262 * Resizes the hash table, if needed.
264 * Essentially, calls g_hash_table_resize() if the table has strayed
265 * too far from its ideal size for its number of nodes.
268 g_hash_table_maybe_resize (GHashTable *hash_table)
270 gint nnodes = hash_table->nnodes;
271 gint size = hash_table->size;
273 if ((size >= 3 * nnodes && size > HASH_TABLE_MIN_SIZE) ||
274 (3 * size <= nnodes && size < HASH_TABLE_MAX_SIZE))
275 g_hash_table_resize (hash_table);
280 * @hash_func: a function to create a hash value from a key.
281 * Hash values are used to determine where keys are stored within the
282 * #GHashTable data structure. The g_direct_hash(), g_int_hash() and
283 * g_str_hash() functions are provided for some common types of keys.
284 * If hash_func is %NULL, g_direct_hash() is used.
285 * @key_equal_func: a function to check two keys for equality. This is
286 * used when looking up keys in the #GHashTable. The g_direct_equal(),
287 * g_int_equal() and g_str_equal() functions are provided for the most
288 * common types of keys. If @key_equal_func is %NULL, keys are compared
289 * directly in a similar fashion to g_direct_equal(), but without the
290 * overhead of a function call.
292 * Creates a new #GHashTable with a reference count of 1.
294 * Return value: a new #GHashTable.
297 g_hash_table_new (GHashFunc hash_func,
298 GEqualFunc key_equal_func)
300 return g_hash_table_new_full (hash_func, key_equal_func, NULL, NULL);
305 * g_hash_table_new_full:
306 * @hash_func: a function to create a hash value from a key.
307 * @key_equal_func: a function to check two keys for equality.
308 * @key_destroy_func: a function to free the memory allocated for the key
309 * used when removing the entry from the #GHashTable or %NULL if you
310 * don't want to supply such a function.
311 * @value_destroy_func: a function to free the memory allocated for the
312 * value used when removing the entry from the #GHashTable or %NULL if
313 * you don't want to supply such a function.
315 * Creates a new #GHashTable like g_hash_table_new() with a reference count
316 * of 1 and allows to specify functions to free the memory allocated for the
317 * key and value that get called when removing the entry from the #GHashTable.
319 * Return value: a new #GHashTable.
322 g_hash_table_new_full (GHashFunc hash_func,
323 GEqualFunc key_equal_func,
324 GDestroyNotify key_destroy_func,
325 GDestroyNotify value_destroy_func)
327 GHashTable *hash_table;
329 hash_table = g_slice_new (GHashTable);
330 hash_table->size = HASH_TABLE_MIN_SIZE;
331 hash_table->nnodes = 0;
332 hash_table->hash_func = hash_func ? hash_func : g_direct_hash;
333 hash_table->key_equal_func = key_equal_func;
334 hash_table->ref_count = 1;
335 hash_table->key_destroy_func = key_destroy_func;
336 hash_table->value_destroy_func = value_destroy_func;
337 hash_table->nodes = g_new0 (GHashNode*, hash_table->size);
345 * @hash_table: a valid #GHashTable.
347 * Atomically increments the reference count of @hash_table by one.
348 * This function is MT-safe and may be called from any thread.
350 * Return value: the passed in #GHashTable.
355 g_hash_table_ref (GHashTable *hash_table)
357 g_return_val_if_fail (hash_table != NULL, NULL);
358 g_return_val_if_fail (hash_table->ref_count > 0, hash_table);
360 g_atomic_int_add (&hash_table->ref_count, 1);
365 * g_hash_table_unref:
366 * @hash_table: a valid #GHashTable.
368 * Atomically decrements the reference count of @hash_table by one.
369 * If the reference count drops to 0, all keys and values will be
370 * destroyed, and all memory allocated by the hash table is released.
371 * This function is MT-safe and may be called from any thread.
376 g_hash_table_unref (GHashTable *hash_table)
378 g_return_if_fail (hash_table != NULL);
379 g_return_if_fail (hash_table->ref_count > 0);
381 if (g_atomic_int_exchange_and_add (&hash_table->ref_count, -1) - 1 == 0)
383 g_hash_table_remove_all_nodes (hash_table, TRUE);
384 g_free (hash_table->nodes);
385 g_slice_free (GHashTable, hash_table);
390 * g_hash_table_destroy:
391 * @hash_table: a #GHashTable.
393 * Destroys all keys and values in the #GHashTable and decrements its
394 * reference count by 1. If keys and/or values are dynamically allocated,
395 * you should either free them first or create the #GHashTable with destroy
396 * notifiers using g_hash_table_new_full(). In the latter case the destroy
397 * functions you supplied will be called on all keys and values during the
401 g_hash_table_destroy (GHashTable *hash_table)
403 g_return_if_fail (hash_table != NULL);
404 g_return_if_fail (hash_table->ref_count > 0);
406 g_hash_table_remove_all (hash_table);
407 g_hash_table_unref (hash_table);
411 * g_hash_table_lookup:
412 * @hash_table: a #GHashTable.
413 * @key: the key to look up.
415 * Looks up a key in a #GHashTable. Note that this function cannot
416 * distinguish between a key that is not present and one which is present
417 * and has the value %NULL. If you need this distinction, use
418 * g_hash_table_lookup_extended().
420 * Return value: the associated value, or %NULL if the key is not found.
423 g_hash_table_lookup (GHashTable *hash_table,
428 g_return_val_if_fail (hash_table != NULL, NULL);
430 node = *g_hash_table_lookup_node (hash_table, key, NULL);
432 return node ? node->value : NULL;
436 * g_hash_table_lookup_extended:
437 * @hash_table: a #GHashTable.
438 * @lookup_key: the key to look up.
439 * @orig_key: returns the original key.
440 * @value: returns the value associated with the key.
442 * Looks up a key in the #GHashTable, returning the original key and the
443 * associated value and a #gboolean which is %TRUE if the key was found. This
444 * is useful if you need to free the memory allocated for the original key,
445 * for example before calling g_hash_table_remove().
447 * Return value: %TRUE if the key was found in the #GHashTable.
450 g_hash_table_lookup_extended (GHashTable *hash_table,
451 gconstpointer lookup_key,
457 g_return_val_if_fail (hash_table != NULL, FALSE);
459 node = *g_hash_table_lookup_node (hash_table, lookup_key, NULL);
465 *orig_key = node->key;
468 *value = node->value;
474 * g_hash_table_insert_internal:
475 * @hash_table: our #GHashTable
476 * @key: the key to insert
477 * @value: the value to insert
478 * @keep_new_key: if %TRUE and this key already exists in the table
479 * then call the destroy notify function on the old key. If %FALSE
480 * then call the destroy notify function on the new key.
482 * Implements the common logic for the g_hash_table_insert() and
483 * g_hash_table_replace() functions.
485 * Do a lookup of @key. If it is found, replace it with the new
486 * @value (and perhaps the new @key). If it is not found, create a
490 g_hash_table_insert_internal (GHashTable *hash_table,
493 gboolean keep_new_key)
495 GHashNode **node_ptr, *node;
498 g_return_if_fail (hash_table != NULL);
499 g_return_if_fail (hash_table->ref_count > 0);
501 node_ptr = g_hash_table_lookup_node (hash_table, key, &key_hash);
503 if ((node = *node_ptr))
507 if (hash_table->key_destroy_func)
508 hash_table->key_destroy_func (node->key);
513 if (hash_table->key_destroy_func)
514 hash_table->key_destroy_func (key);
517 if (hash_table->value_destroy_func)
518 hash_table->value_destroy_func (node->value);
524 node = g_slice_new (GHashNode);
528 node->key_hash = key_hash;
532 hash_table->nnodes++;
533 g_hash_table_maybe_resize (hash_table);
538 * g_hash_table_insert:
539 * @hash_table: a #GHashTable.
540 * @key: a key to insert.
541 * @value: the value to associate with the key.
543 * Inserts a new key and value into a #GHashTable.
545 * If the key already exists in the #GHashTable its current value is replaced
546 * with the new value. If you supplied a @value_destroy_func when creating the
547 * #GHashTable, the old value is freed using that function. If you supplied
548 * a @key_destroy_func when creating the #GHashTable, the passed key is freed
549 * using that function.
552 g_hash_table_insert (GHashTable *hash_table,
556 return g_hash_table_insert_internal (hash_table, key, value, FALSE);
560 * g_hash_table_replace:
561 * @hash_table: a #GHashTable.
562 * @key: a key to insert.
563 * @value: the value to associate with the key.
565 * Inserts a new key and value into a #GHashTable similar to
566 * g_hash_table_insert(). The difference is that if the key already exists
567 * in the #GHashTable, it gets replaced by the new key. If you supplied a
568 * @value_destroy_func when creating the #GHashTable, the old value is freed
569 * using that function. If you supplied a @key_destroy_func when creating the
570 * #GHashTable, the old key is freed using that function.
573 g_hash_table_replace (GHashTable *hash_table,
577 return g_hash_table_insert_internal (hash_table, key, value, TRUE);
581 * g_hash_table_remove_internal:
582 * @hash_table: our #GHashTable
583 * @key: the key to remove
584 * @notify: %TRUE if the destroy notify handlers are to be called
585 * Return value: %TRUE if a node was found and removed, else %FALSE
587 * Implements the common logic for the g_hash_table_remove() and
588 * g_hash_table_steal() functions.
590 * Do a lookup of @key and remove it if it is found, calling the
591 * destroy notify handlers only if @notify is %TRUE.
594 g_hash_table_remove_internal (GHashTable *hash_table,
598 GHashNode **node_ptr;
600 g_return_val_if_fail (hash_table != NULL, FALSE);
602 node_ptr = g_hash_table_lookup_node (hash_table, key, NULL);
603 if (*node_ptr == NULL)
606 g_hash_table_remove_node (hash_table, &node_ptr, notify);
607 g_hash_table_maybe_resize (hash_table);
613 * g_hash_table_remove:
614 * @hash_table: a #GHashTable.
615 * @key: the key to remove.
617 * Removes a key and its associated value from a #GHashTable.
619 * If the #GHashTable was created using g_hash_table_new_full(), the
620 * key and value are freed using the supplied destroy functions, otherwise
621 * you have to make sure that any dynamically allocated values are freed
624 * Return value: %TRUE if the key was found and removed from the #GHashTable.
627 g_hash_table_remove (GHashTable *hash_table,
630 return g_hash_table_remove_internal (hash_table, key, TRUE);
634 * g_hash_table_steal:
635 * @hash_table: a #GHashTable.
636 * @key: the key to remove.
638 * Removes a key and its associated value from a #GHashTable without
639 * calling the key and value destroy functions.
641 * Return value: %TRUE if the key was found and removed from the #GHashTable.
644 g_hash_table_steal (GHashTable *hash_table,
647 return g_hash_table_remove_internal (hash_table, key, FALSE);
651 * g_hash_table_remove_all:
652 * @hash_table: a #GHashTable
654 * Removes all keys and their associated values from a #GHashTable.
656 * If the #GHashTable was created using g_hash_table_new_full(), the keys
657 * and values are freed using the supplied destroy functions, otherwise you
658 * have to make sure that any dynamically allocated values are freed
664 g_hash_table_remove_all (GHashTable *hash_table)
666 g_return_if_fail (hash_table != NULL);
668 g_hash_table_remove_all_nodes (hash_table, TRUE);
669 g_hash_table_maybe_resize (hash_table);
673 * g_hash_table_steal_all:
674 * @hash_table: a #GHashTable.
676 * Removes all keys and their associated values from a #GHashTable
677 * without calling the key and value destroy functions.
682 g_hash_table_steal_all (GHashTable *hash_table)
684 g_return_if_fail (hash_table != NULL);
686 g_hash_table_remove_all_nodes (hash_table, FALSE);
687 g_hash_table_maybe_resize (hash_table);
691 * g_hash_table_foreach_remove_or_steal:
692 * @hash_table: our #GHashTable
693 * @func: the user's callback function
694 * @user_data: data for @func
695 * @notify: %TRUE if the destroy notify handlers are to be called
697 * Implements the common logic for g_hash_table_foreach_remove() and
698 * g_hash_table_foreach_steal().
700 * Iterates over every node in the table, calling @func with the key
701 * and value of the node (and @user_data). If @func returns %TRUE the
702 * node is removed from the table.
704 * If @notify is true then the destroy notify handlers will be called
705 * for each removed node.
708 g_hash_table_foreach_remove_or_steal (GHashTable *hash_table,
713 GHashNode *node, **node_ptr;
717 for (i = 0; i < hash_table->size; i++)
718 for (node_ptr = &hash_table->nodes[i]; (node = *node_ptr) != NULL;)
719 if ((* func) (node->key, node->value, user_data))
721 g_hash_table_remove_node (hash_table, &node_ptr, notify);
725 node_ptr = &node->next;
727 g_hash_table_maybe_resize (hash_table);
733 * g_hash_table_foreach_remove:
734 * @hash_table: a #GHashTable.
735 * @func: the function to call for each key/value pair.
736 * @user_data: user data to pass to the function.
738 * Calls the given function for each key/value pair in the #GHashTable.
739 * If the function returns %TRUE, then the key/value pair is removed from the
740 * #GHashTable. If you supplied key or value destroy functions when creating
741 * the #GHashTable, they are used to free the memory allocated for the removed
744 * Return value: the number of key/value pairs removed.
747 g_hash_table_foreach_remove (GHashTable *hash_table,
751 g_return_val_if_fail (hash_table != NULL, 0);
752 g_return_val_if_fail (func != NULL, 0);
754 return g_hash_table_foreach_remove_or_steal (hash_table, func, user_data, TRUE);
758 * g_hash_table_foreach_steal:
759 * @hash_table: a #GHashTable.
760 * @func: the function to call for each key/value pair.
761 * @user_data: user data to pass to the function.
763 * Calls the given function for each key/value pair in the #GHashTable.
764 * If the function returns %TRUE, then the key/value pair is removed from the
765 * #GHashTable, but no key or value destroy functions are called.
767 * Return value: the number of key/value pairs removed.
770 g_hash_table_foreach_steal (GHashTable *hash_table,
774 g_return_val_if_fail (hash_table != NULL, 0);
775 g_return_val_if_fail (func != NULL, 0);
777 return g_hash_table_foreach_remove_or_steal (hash_table, func, user_data, FALSE);
781 * g_hash_table_foreach:
782 * @hash_table: a #GHashTable.
783 * @func: the function to call for each key/value pair.
784 * @user_data: user data to pass to the function.
786 * Calls the given function for each of the key/value pairs in the
787 * #GHashTable. The function is passed the key and value of each
788 * pair, and the given @user_data parameter. The hash table may not
789 * be modified while iterating over it (you can't add/remove
790 * items). To remove all items matching a predicate, use
791 * g_hash_table_foreach_remove().
793 * See g_hash_table_find() for performance caveats for linear
794 * order searches in contrast to g_hash_table_lookup().
797 g_hash_table_foreach (GHashTable *hash_table,
804 g_return_if_fail (hash_table != NULL);
805 g_return_if_fail (func != NULL);
807 for (i = 0; i < hash_table->size; i++)
808 for (node = hash_table->nodes[i]; node; node = node->next)
809 (* func) (node->key, node->value, user_data);
814 * @hash_table: a #GHashTable.
815 * @predicate: function to test the key/value pairs for a certain property.
816 * @user_data: user data to pass to the function.
818 * Calls the given function for key/value pairs in the #GHashTable until
819 * @predicate returns %TRUE. The function is passed the key and value of
820 * each pair, and the given @user_data parameter. The hash table may not
821 * be modified while iterating over it (you can't add/remove items).
823 * Note, that hash tables are really only optimized for forward lookups,
824 * i.e. g_hash_table_lookup().
825 * So code that frequently issues g_hash_table_find() or
826 * g_hash_table_foreach() (e.g. in the order of once per every entry in a
827 * hash table) should probably be reworked to use additional or different
828 * data structures for reverse lookups (keep in mind that an O(n) find/foreach
829 * operation issued for all n values in a hash table ends up needing O(n*n)
832 * Return value: The value of the first key/value pair is returned, for which
833 * func evaluates to %TRUE. If no pair with the requested property is found,
839 g_hash_table_find (GHashTable *hash_table,
846 g_return_val_if_fail (hash_table != NULL, NULL);
847 g_return_val_if_fail (predicate != NULL, NULL);
849 for (i = 0; i < hash_table->size; i++)
850 for (node = hash_table->nodes[i]; node; node = node->next)
851 if (predicate (node->key, node->value, user_data))
858 * @hash_table: a #GHashTable.
860 * Returns the number of elements contained in the #GHashTable.
862 * Return value: the number of key/value pairs in the #GHashTable.
865 g_hash_table_size (GHashTable *hash_table)
867 g_return_val_if_fail (hash_table != NULL, 0);
869 return hash_table->nnodes;
873 * g_hash_table_get_keys:
874 * @hash_table: a #GHashTable
876 * Retrieves every key inside @hash_table. The returned data is valid
877 * until @hash_table is modified.
879 * Return value: a #GList containing all the keys inside the hash
880 * table. The content of the list is owned by the hash table and
881 * should not be modified or freed. Use g_list_free() when done
887 g_hash_table_get_keys (GHashTable *hash_table)
893 g_return_val_if_fail (hash_table != NULL, NULL);
896 for (i = 0; i < hash_table->size; i++)
897 for (node = hash_table->nodes[i]; node; node = node->next)
898 retval = g_list_prepend (retval, node->key);
904 * g_hash_table_get_values:
905 * @hash_table: a #GHashTable
907 * Retrieves every value inside @hash_table. The returned data is
908 * valid until @hash_table is modified.
910 * Return value: a #GList containing all the values inside the hash
911 * table. The content of the list is owned by the hash table and
912 * should not be modified or freed. Use g_list_free() when done
918 g_hash_table_get_values (GHashTable *hash_table)
924 g_return_val_if_fail (hash_table != NULL, NULL);
927 for (i = 0; i < hash_table->size; i++)
928 for (node = hash_table->nodes[i]; node; node = node->next)
929 retval = g_list_prepend (retval, node->value);
935 #include "galiasdef.c"