Xavier Claessens
6fcaa7aa96
GHashTable: Explicitly document that _iter_remove() is safe while iterating
...
https://bugzilla.gnome.org/show_bug.cgi?id=723316
2014-02-21 15:39:31 -05:00
William Jon McCann
20f4d1820b
docs: use "Returns:" consistently
...
Instead of "Return value:".
2014-02-19 19:41:52 -05:00
Matthias Clasen
bc6ee788b4
docs: let go of *
...
Since we are no longer using sgml mode, using /* */ to
escape block comments inside examples does not work anymore.
Switch to using line comments with //
2014-02-14 21:33:36 -05:00
Matthias Clasen
e7fd3de86d
Eradicate links and xrefs
...
These are all replaced by markdown ref links.
2014-02-08 12:26:56 -05:00
Matthias Clasen
3232425785
Docs: replace <literal> by `
2014-02-06 08:07:16 -05:00
Matthias Clasen
cb588d4532
Convert external links to markdown syntax
2014-02-05 21:23:28 -05:00
Matthias Clasen
adf892e96a
Annotate all examples with their language
...
The C ones, at least.
2014-02-01 15:11:49 -05:00
Daniel Mustieles
078dbda148
Updated FSF's address
2014-01-31 14:31:55 +01:00
Simon McVittie
a4480d5f71
GHashTable: statically assert that GHashTableIter works as intended
...
https://bugzilla.gnome.org/show_bug.cgi?id=688406
2014-01-19 20:23:43 -05:00
Matthias Clasen
910191597a
Add boolean returns to some hash functions
...
The functions g_hash_table_insert, g_hash_table_replace
and g_hash_table_add now return TRUE if they inserted a
new key/value pair.
https://bugzilla.gnome.org/show_bug.cgi?id=697828
2013-11-24 01:22:44 -05:00
Ryan Lortie
2880767702
Add g_hash_table_get_keys_as_array()
...
Returns a %NULL-terminated array of the keys of a hashtable.
In the case that the hash table has strings for keys, this is actually a
gchar**.
https://bugzilla.gnome.org/show_bug.cgi?id=710964
2013-10-27 09:26:53 -07:00
Colin Walters
e359130e3e
ghash: Suppress -Wmaybe-uninitialized from GCC 4.4
...
It's not clever enough to figure out that these are always initialized
in code paths that use them.
Reviewed-By: Benjamin Otte <otte@gnome.org >
2013-04-02 14:14:42 -04:00
Matthias Clasen
5825dd864b
g_hash_table_get_keys: Improve docs slightly
...
https://bugzilla.gnome.org/show_bug.cgi?id=630284
2013-03-17 23:30:34 -04:00
Ryan Lortie
bb1df4d01b
hashtable: properly handle insert() de-set-ifying
...
GHashTable remains a set for as long as all of the keys are exactly
equal (in pointer value) to all of the values. We check this by
comparing keys to values when we do inserts.
Unfortunately, when doing g_hash_table_insert() when a key is already in
the table, the old key pointer value is kept, but the new value pointer
is used. Now we have a situation where a key pointer is unequal to a
value pointer, but we were not treating this case properly.
Fix that.
https://bugzilla.gnome.org/show_bug.cgi?id=692815
2013-02-02 00:34:01 -05:00
Dan Winship
132c4cee4f
ghash.c: fix docs
...
A previous commit left an unclosed XML tag. Fix that.
2012-10-10 10:03:15 -04:00
Jasper St. Pierre
d9730f0e31
ghash: Add documentation
2012-10-07 20:12:03 -03:00
Robert Ancell
4143842eb4
Add missing allow-none annotations for function parameters.
...
Found using:
find . -name '*.c' | xargs grep 'or %NULL' | grep ' \* @' | grep -v '@error' | grep -v allow-none
2012-03-31 20:34:28 +11:00
Christophe Fergeau
6d3b31a533
Fix g_hash_table_foreach crash with NULL hash table
...
When G_DISABLE_ASSERT is not defined, g_hash_table_foreach and
g_hash_table_find dereferences the hash table argument before
checking if it's NULL. This causes a crash when one of this function
is mistakenly called with a NULL argument instead of returning
with a warning through g_return_if_fail.
2012-02-10 10:03:38 +01:00
Ryan Lortie
12060df9f1
GHash: add note about randomness in hashing
...
To clarify our statements about being robust against outside attackers
degrading the performance of your hashtable.
2012-01-25 10:09:09 -05:00
Matthias Clasen
030b3f25e3
GHashTable: Add a note about hash collisions
2012-01-24 21:11:13 -05:00
Philip Withnall
e98f17e5cf
Bug 666700 — Add some missing (allow-none) annotations
...
Add some missing (allow-none) annotations to GContentType, GIcon and
GHashTable methods.
Closes: bgo#666700
2012-01-11 20:48:29 +00:00
Matthias Clasen
39dc681fc7
Realign the hash set example with added api
...
Change the name of set_insert to set_add, to better match the
newly added g_hash_table_add.
2012-01-09 15:23:25 -05:00
Ryan Lortie
752f0cac15
GHashTable: new 'add' and 'contains' APIs
...
These are both convenience APIs that make it slightly nicer to use
GHashTable as a set (which is something we document as officially
supported).
2012-01-06 10:18:41 -05:00
Matthias Clasen
73e3c98df0
Fix g_hash_table_iter_replace
...
When reusing an existing key 'internally', we must avoid calling
the key_destroy function on the old key.
https://bugzilla.gnome.org/show_bug.cgi?id=662544
2011-10-24 13:29:17 -04:00
Simon McVittie
f778564ba2
Be clear that g_str_hash etc. don't accept NULL
...
This covers the str, double, int, int64 hash and equal functions, but not
anything that takes an "object", since the convention is that "object
methods" never accept NULL anyway.
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=592715
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk >
Reviewed-by: Colin Walters <walters@verbum.org >
2011-10-04 09:48:35 +01:00
Simon McVittie
34a1224549
Be completely clear about what g_direct_hash, g_direct_equal do
...
Also annotate them as (allow-none), more for the benefit of gtk-doc
readers than introspection.
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=592715
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk >
Reviewed-by: Colin Walters <walters@verbum.org >
2011-10-04 09:44:27 +01:00
Simon McVittie
06c96ab1e5
GHashTable: be more clear what g_int_hash wants
...
Using g_int_hash, g_int_equal with keys like GINT_TO_POINTER (n) seems to
be a reasonably common GLib-novice mistake. It doesn't help that the
documentation for GHashFunc was ambiguous about this.
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=592715
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk >
Reviewed-by: Colin Walters <walters@verbum.org >
2011-10-04 09:42:28 +01:00
Matthias Clasen
6ef022bbb3
Move all hash functions to ghash.c
...
This matches their location in the headers.
2011-10-02 00:08:54 -04:00
Matthias Clasen
e7ca67f20c
GHash: Cosmetic changes
2011-10-02 00:08:13 -04:00
Ryan Lortie
37c740d509
Don't #include <glib/gslice.h> from gmem.h
...
It looks like this was done just to help people port from gmem to
gslice, but nothing in this header actually requires gslice.h to be
included.
2011-09-18 22:07:18 -04:00
Ryan Lortie
e1b41dcb91
ghash: fix error in "as a set" documentation
2011-08-15 10:43:25 -04:00
Philip Van Hoof
f6ed357101
Add iter_replace API to GHashTableIter
...
https://bugzilla.gnome.org/show_bug.cgi?id=652822
2011-06-20 23:05:59 -04:00
Matthias Clasen
666adc2dc0
Volatile not necessary after all
...
I was temporarily confused.
2011-05-28 22:33:37 -04:00
Matthias Clasen
abf719362a
GHash: Avoid nonatomic access to the reference count
...
Not really necessary to constantly double-check the ref
count, anyway.
2011-05-28 21:40:12 -04:00
Matthias Clasen
5d7b67a6c3
Preserve consistency when removing all nodes from a hash table
...
During the recent refactorings of GHashTable a bug was introduced
where removing all nodes from a hash table would leave tombstones
behind, but make the counts appear like there are none.
Reported and tracked down by Carlos Garnacho,
https://bugzilla.gnome.org/show_bug.cgi?id=651141
This commit also adds a test that checks the internal consistency
of GHashTable over several insert/remove/remove-all operations.
2011-05-26 21:52:50 -04:00
Matthias Clasen
88f23fb1d9
Cosmetics
...
Use g_atomic_int_inc/dec instead of add(...,1/-1), since
this is the way refcounting is done elsewhere. Some other
cosmetic changes.
2011-05-23 00:40:33 -04:00
Matthias Clasen
f924384634
Trivial: fix a typo
2011-05-21 20:56:04 -04:00
Matthias Clasen
120b85a31b
Enforce rules about modifying hash tables in callbacks
...
We have the infrastructure to do this, so lets do it.
Also add tests for find and foreach to the testsuite.
Bug 650688
2011-05-20 15:07:08 -04:00
Matthias Clasen
afc5319a27
Be more careful when calling destroy notifies
...
If we are, we can allow modification of the hash table
from destroy notifies.
https://bugzilla.gnome.org/show_bug.cgi?id=650459
2011-05-19 23:51:43 -04:00
Dan Winship
bdc23c44e8
Fix compiler warnings
2011-05-02 11:50:23 -04:00
Matthias Clasen
d09df426ba
GHash: make sets with refcounted keys work correctly
...
When keys == values, we have to be careful about the order in
which we replace their elements.
2011-05-01 10:55:24 -04:00
Matthias Clasen
be991170fa
GHash: introduce a "set" mode
...
Make hash tables start out in a mode in which they don't store
values at all, until the first insertion of a non-identical
key-value pair.
This reduces memory requirements by 1/3 when using hash tables
to store sets.
Based on a patch by Morten Welinder,
https://bugzilla.gnome.org/show_bug.cgi?id=644437
2011-04-30 23:11:18 -04:00
Morten Welinder
0ae6bc3aaa
GHash: eliminate one of the lookup_nodes functions.
...
Kill g_hash_table_lookup_node and rename g_hash_table_lookup_node_for_insertion
to g_hash_table_lookup_node. Since at this point we already check for
toombstones in all callers of g_hash_table_lookup_node this doesn't make
a difference.
https://bugzilla.gnome.org/show_bug.cgi?id=644437
2011-04-30 23:11:18 -04:00
Morten Welinder
6e45153ef7
GHash: split nodes array into seperate arrays.
...
This reduces memory requirements by 1/6 on 64-bit machines since
no padding is needed. It also puts less strain on the memory
allocator since we no longer need one giant slab of memory.
https://bugzilla.gnome.org/show_bug.cgi?id=644437
2011-04-30 23:11:18 -04:00
Morten Welinder
4d8e64e6e8
GHash: use macros to check for magic hash values.
...
https://bugzilla.gnome.org/show_bug.cgi?id=644437
2011-04-30 23:11:18 -04:00
Matthias Clasen
d3b80c49ea
GHashTable: Small optimization of remove-all
...
Don't enter the loop if we are not going to notify anyway.
Pointed out in bug 646013.
2011-04-27 00:03:59 -04:00
Matthias Clasen
d2d756439f
GHashTable: Clarify g_hash_table_lookup_extended docs
...
Passing NULL as a key is only ok if your hash and equal functions
can deal with it.
https://bugzilla.gnome.org/show_bug.cgi?id=642944
2011-02-25 10:40:39 -05:00
Johan Dahlin
fdaaa22b58
Correct gtk-doc SECTION: syntax
...
g-ir-scanner does not allow a space between the : and the
section name.
2011-02-01 16:18:02 -02:00
Emmanuele Bassi
ca7dee5949
Build fixes for the fall-out of the inclusion changes
2010-09-04 18:04:34 +01:00
Matthias Clasen
04077ff5c5
More include cleanups
2010-09-03 23:03:14 -04:00