summaryrefslogtreecommitdiff
path: root/glib/ghash.c
Commit message (Collapse)AuthorAgeFilesLines
* Correct gtk-doc SECTION: syntaxJohan Dahlin2011-02-011-1/+1
| | | | | g-ir-scanner does not allow a space between the : and the section name.
* Build fixes for the fall-out of the inclusion changesEmmanuele Bassi2010-09-041-0/+1
|
* More include cleanupsMatthias Clasen2010-09-031-1/+4
|
* glib/: fully remove galias hacksRyan Lortie2010-07-071-4/+0
|
* gtk-doc fixupsRyan Lortie2010-03-211-2/+2
|
* GHash: move docs from tmpl to inline commentsRyan Lortie2010-01-281-0/+114
|
* Bug 580453 – Hash and equal functions for gint64 and gdoubleDavid Zeuthen2009-04-271-6/+7
|
* Bug 558672 – NULL key lookup using g_hash_table_lookup_extended()Christian Dywan2008-11-041-4/+7
| | | | | | | | | | | 2008-11-04 Christian Dywan <christian@imendio.com> Bug 558672 – NULL key lookup using g_hash_table_lookup_extended() * glib/ghash.c: Clarify g_hash_table_lookup_extended svn path=/trunk/; revision=7644
* changed "#GHashTableIterator" to "#GHashTableIter" in theJoseph Pingenot2008-10-271-2/+2
| | | | | | | | | | | | | * glib/ghash.c: changed "#GHashTableIterator" to "#GHashTableIter" in the documentation-comments above g_hash_table_foreach_remove() and g_hash_table_foreach_steal() to correctly name and link to GHashTableIter. This affects the GNOME documentation website as well, so further steps are likely necessary beyond this subproject. * ChangeLog modified to reflect this. -Joseph (solarion) svn path=/trunk/; revision=7631
* Rewrite most of GHashTable to use open addressing with quadratic probingHans Petter Jansson2008-09-201-219/+360
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 2008-09-19 Hans Petter Jansson <hpj@novell.com> Rewrite most of GHashTable to use open addressing with quadratic probing instead of chaining. This has the potential to reduce memory fragmentation significantly, while being slightly faster due to better locality and no need to call alloc/free functions for nodes. Benchmarks suggest it also uses less memory overall. * glib/ghash.c (prime_mod): Table of suitable primes for initial-probe distribution. (g_hash_table_set_shift): New function. (g_hash_table_find_closest_shift): New function. (g_hash_table_set_shift_from_size): New function. (g_hash_table_lookup_node_for_insertion): New function. (g_hash_table_lookup_node): Rewritten to return node index instead of pointer, use quadratic probe on flat table, and not return insertion data. The latter saves some computation for read-only lookups. (g_hash_table_remove_node): Rewrite to take a pointer directly to the node structure to remove, and clear that. Remove unlinking code. (g_hash_table_remove_all_nodes): Rewrite to not clear nodes individually, but en masse using memset () after potentially calling notify functions. (iter_remove_or_steal): Use new data structure and algorithm. Vastly simplified - now just a call to g_hash_table_remove_node (). (g_hash_table_resize): New resize code, re-indexing with new prime and cleaning up tombstones. (g_hash_table_maybe_resize): Table may hold 8 buckets minimum, no less than 1/4 load excluding tombstones, and no more than 15/16 load including tombstones. These numbers are the results of a lot of benchmarking with multiple complex applications, and should not be changed lightly. (g_hash_table_iter_next) (g_hash_table_lookup) (g_hash_table_lookup_extended) (g_hash_table_insert_internal) (g_hash_table_remove_internal) (g_hash_table_foreach_remove_or_steal) (g_hash_table_foreach) (g_hash_table_find) (g_hash_table_get_keys) (g_hash_table_get_values): Use new data structure and algorithm, fairly trivial changes. svn path=/trunk/; revision=7518
* Bug 536158 – also bump GHashTable version when a node is removed viaMatthias Clasen2008-06-101-0/+5
| | | | | | | | | | g_hash_table_iter_remove()/g_hash_table_iter_steal() * glib/ghash.c (iter_remove_or_steal): Bump the hash table version. Patch by Jean-Yves Lefort svn path=/trunk/; revision=6993
* Fix the build with -DG_DISABLE_ASSERT. (#525060, Arfrever FrehtesMatthias Clasen2008-03-311-0/+4
| | | | | | | | | | | 2008-03-30 Matthias Clasen <mclasen@redhat.com> * glib/ghash.c: Fix the build with -DG_DISABLE_ASSERT. (#525060, Arfrever Frehtes Taifersar Arahesis) svn path=/trunk/; revision=6777
* These functions prototype defines its output as void, and therefore theyAlvaro Lopez Ortega2008-01-021-2/+2
| | | | | | | | | | | 2008-01-02 Alvaro Lopez Ortega <alvaro@sun.com> * glib/ghash.c (g_hash_table_replace, g_hash_table_insert): These functions prototype defines its output as void, and therefore they should not return any value. This patch fixes a compilation error: the "return" clauses were incompatible with the functions prototype. svn path=/trunk/; revision=6230
* Fix up docsMatthias Clasen2007-12-151-7/+7
| | | | svn path=/trunk/; revision=6131
* Add hash table iterators. (#500507, Jean-Yves Lefort)Matthias Clasen2007-12-151-0/+258
| | | | | | | | | | | | | | 2007-12-14 Matthias Clasen <mclasen@redhat.com> * glib/glib.symbols: * glib/ghash.[hc]: Add hash table iterators. (#500507, Jean-Yves Lefort) * tests/hash-test.c: Test iterators. svn path=/trunk/; revision=6130
* Call destroy notify when destroying the hash table in g_hash_table_unref.Mathias Hasselmann2007-12-061-1/+1
| | | | | | | * glib/ghash.c: Call destroy notify when destroying the hash table in g_hash_table_unref. svn path=/trunk/; revision=6060
* ungtk-docify some comments for internal functionsRyan Lortie2007-12-051-16/+16
| | | | | | | | | 2007-12-05 Ryan Lortie <desrt@desrt.ca> * glib/ghash.c: ungtk-docify some comments for internal functions svn path=/trunk/; revision=6045
* no code changes; add comments to document the internal functions.Ryan Lortie2007-12-041-0/+134
| | | | | | | | | | 2007-12-03 Ryan Lortie <desrt@desrt.ca> * glib/ghash.c: no code changes; add comments to document the internal functions. svn path=/trunk/; revision=6037
* no code changes; reorder functions to remove the need for forwardRyan Lortie2007-12-041-171/+157
| | | | | | | | | | 2007-12-03 Ryan Lortie <desrt@desrt.ca> * glib/ghash.c: no code changes; reorder functions to remove the need for forward declarations. svn path=/trunk/; revision=6036
* improve clarity in some functionsRyan Lortie2007-12-041-38/+44
| | | | | | | | | | | 2007-12-03 Ryan Lortie <desrt@desrt.ca> * glib/ghash.c (g_hash_table_lookup_node, g_hash_table_lookup_extended, g_hash_table_insert_internal, g_hash_node_new): improve clarity in some functions svn path=/trunk/; revision=6035
* rename 'node' to 'node_ptr' where appropriateRyan Lortie2007-12-041-16/+16
| | | | | | | | | 2007-12-03 Ryan Lortie <desrt@desrt.ca> * glib/ghash.c: rename 'node' to 'node_ptr' where appropriate svn path=/trunk/; revision=6034
* convert G_HASH_TABLE_RESIZE() macro to inline functionRyan Lortie2007-12-041-14/+15
| | | | | | | | | 2007-12-03 Ryan Lortie <desrt@desrt.ca> * glib/ghash.c: convert G_HASH_TABLE_RESIZE() macro to inline function svn path=/trunk/; revision=6033
* only whitespace fixes, mostly removing spaces at ends of lines (and on empty ↵Ryan Lortie2007-12-041-117/+117
| | | | | | lines) svn path=/trunk/; revision=6030
* create a common function for the many places where all nodes in the tableRyan Lortie2007-12-031-67/+27
| | | | | | | | | | | | 2007-12-03 Ryan Lortie <desrt@desrt.ca> * glib/ghash.c: create a common function for the many places where all nodes in the table are removed (remove_all, steal_all, destroy, unref, etc...) svn path=/trunk/; revision=6026
* merge more common code into functions. Vastly simplify loop logic inRyan Lortie2007-12-031-76/+54
| | | | | | | | | | 2007-12-03 Ryan Lortie <desrt@desrt.ca> * glib/ghash.c: merge more common code into functions. Vastly simplify loop logic in g_hash_table_foreach_remove_or_steal(). svn path=/trunk/; revision=6016
* nothing to see here... move along, move along :)Ryan Lortie2007-11-281-3/+7
| | | | svn path=/trunk/; revision=5965
* insert/replace were identical except for a single line. Replace both withRyan Lortie2007-11-281-50/+34
| | | | | | | | | | | 2007-11-27 Ryan Lortie <desrt@desrt.ca> * glib/ghash.c (g_hash_table_insert, g_hash_table_replace, g_hash_table_insert_internal): insert/replace were identical except for a single line. Replace both with a common function. svn path=/trunk/; revision=5964
* g_hash_table_find(), g_hash_table_foreach(): document performance caveatsTim Janik2007-06-251-3/+15
| | | | | | | | | | | Mon Jun 25 16:43:13 2007 Tim Janik <timj@gtk.org> * glib/ghash.c: g_hash_table_find(), g_hash_table_foreach(): document performance caveats for linear order searches. svn path=/trunk/; revision=5587
* Add g_hash_table_get_keys() and g_hash_table_get_values(), API to retrieveEmmanuele Bassi2007-04-111-0/+62
| | | | | | | | | | | | | | 2007-04-11 Emmanuele Bassi <ebassi@gnome.org> * glib/ghash.[ch]: Add g_hash_table_get_keys() and g_hash_table_get_values(), API to retrieve the keys and values inside an hash table in list form. (#413133) * glib/glib.symbols: Update symbols. * tests/hash-test.c: Exercise newly added functions. svn path=/trunk/; revision=5444
* implemented static debugging hash-tree to validate slice adresses andTim Janik2006-12-281-1/+1
| | | | | | | | | | | | | | | | | | | Thu Dec 28 12:50:31 2006 Tim Janik <timj@imendio.com> * glib/gslice.h, glib/gslice.c: implemented static debugging hash-tree to validate slice adresses and sizes with G_SLICE=debug-blocks. use abort() to exit in mem_error() to allow catching of these in gdb. abort programs with a descriptive error message if g_thread_init() is called after GSlice was in use. previously this just silently corrupted the magazines. * glib/ghash.c (struct _GHashNode): reordered fields to keep 8-byte pointer alignment on 64bit systems and request smaller slice sizes on 32bit systems. * tests/slice-test.c: support '~' option flag to introduce slice allocation/release corruption with a significant probability. this allowes testing of G_SLICE=debug-blocks.
* cache the value of the hash function in the GHashNode. this speeds upRyan Lortie2006-12-271-17/+34
| | | | | | | | | 2006-12-27 Ryan Lortie <desrt@desrt.ca> * glib/ghash.c: cache the value of the hash function in the GHashNode. this speeds up resizing the hash table and it also allows a slight optimisation on lookups. (#388332)
* Forgotten fileMatthias Clasen2006-12-181-1/+1
|
* Add g_hash_table_{remove,steal}_all to remove all nodes from a hash table.Matthias Clasen2006-06-011-12/+60
| | | | | | | | | 2006-06-01 Matthias Clasen <mclasen@redhat.com> * glib/glib.symbols: * glib/ghash.h: * glib/ghash.c: Add g_hash_table_{remove,steal}_all to remove all nodes from a hash table. (#168538, Matt Barnes)
* honour g_mem_gc_friendly settings when freeing slices, make sureTim Janik2006-01-251-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | Wed Jan 25 16:39:18 2006 Tim Janik <timj@imendio.com> * glib/gslice.c: honour g_mem_gc_friendly settings when freeing slices, make sure g_mem_gc_friendly is properly initialized. * gmem.[hc]: ensure g_mem_gc_friendly is initialized from G_DEBUG upon the first allocation. applied some branching optimizations. * docs/macros.txt: reflected --enable-gc-friendly change and described ENABLE_GC_FRIENDLY_DEFAULT as well as G_DEBUG=gc-friendly. * configure.in: changed --enable-gc-friendly=yes to define ENABLE_GC_FRIENDLY_DEFAULT. * glib/garray.c: changed ENABLE_GC_FRIENDLY macro #ifdef-s to if (G_UNLIKELY (g_mem_gc_friendly)). * glib/gtree.c: * glib/ghash.c: removed ENABLE_GC_FRIENDLY code which is now taken care of by g_slice_free1(). * tests/slice-test.c: fixed leaks, reported by Kjartan Maraas.
* Silence compiler warnings.Matthias Clasen2005-11-281-3/+4
| | | | | | | | | | | 2005-11-28 Matthias Clasen <mclasen@redhat.com> * glib/gthread.c (g_static_rw_lock_wait, g_static_rw_lock_signal): * glib/gnode.c (g_node_depth_traverse_level): * glib/gmem.c (g_allocator_new): * glib/ghash.c (g_hash_table_unref, g_hash_table_destroy) (g_hash_table_foreach_remove_or_steal): Silence compiler warnings.
* Typo in comment.Morten Welinder2005-11-251-1/+1
|
* Documentation improvementsMatthias Clasen2005-11-231-0/+4
|
* g_hash_table_new_full(): create hash tables with a ref count of 1.Tim Janik2005-11-221-20/+74
| | | | | | | | | | | | | | | | | | Tue Nov 22 14:04:26 2005 Tim Janik <timj@imendio.com> * glib/ghash.h: * glib/ghash.c: g_hash_table_new_full(): create hash tables with a ref count of 1. g_hash_table_ref(): atomically ref_count+=1 g_hash_table_unref(): atomically ref_count-=1, destroys hash table when refcount reaches 0. g_hash_table_destroy(): just destroy keys and values, unref by 1. g_hash_table_insert(): g_hash_table_replace(): assert ref_count>0. * glib/gatomic.h: * glib/gatomic.c: added 'volatile' qualifier to all atomic pointer and integer pointers.
* prepared deprecation of GMemChunk and GAllocator. added g_slice_*() API toTim Janik2005-11-011-79/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Tue Nov 1 16:24:20 2005 Tim Janik <timj@imendio.com> * glib/gmem.[hc]: prepared deprecation of GMemChunk and GAllocator. added g_slice_*() API to allocate and cache small bits of memory. an actuall allocator implementation for g_slice_*() is still pending. * glib/gthread.[hc]: changes from a patch by Matthias Clasen. changed GRealThread list to use in-structure *next; fields instead of GSList, in order for thread iteration to not depenend on g_slice_*() indirectly. _g_thread_mem_private_get(): _g_thread_mem_private_set(): added accessors for private memory, needed because the ordinary GPrivate implementation relies on GArray and GSList and therefore indirectly on working g_slice_*() allocations. * glib/gthread.[hc]: g_thread_foreach(): new public API function to loop over all existing threads. * glib/gdataset.c: * glib/gstring.c: * glib/gcache.c: * glib/garray.c: * glib/gqueue.c: * glib/gslist.c: * glib/glist.c: * glib/ghash.c: * glib/gtree.c: * glib/ghook.c: * glib/gmain.c: * glib/gnode.c: removed GAllocator and free list usages and accompanying locks. use g_slice_*() API to allocate and cache small bits of memory. * glib/ghook.h: removed GMemChunk field from public API. * glib/gslist.h: * glib/glist.h: deprecate allocator API, provide _free1() for consistency. * glib/gnode.h: deprecate allocator API. * glib/gmain.c: reordered GPollRec fields so g_slice_free_chain() can be used for poll rec lists. * glib/grel.c: removed mem chunk usage, and allocated tuples via g_slice_*(). g_relation_destroy(): free all tuples from the all_tuples hash table, this effectively maintains the life time track keeping of tuples. g_relation_delete_tuple(): free tuples which are removed from the all_tuples hash table. this fixes a temporary leak that was present in the memchunk code until the destruction of the relation.
* Fix a typo in the docs. (#311569, Ross Burton)Matthias Clasen2005-07-261-1/+1
| | | | | | | 2005-07-26 Matthias Clasen <mclasen@redhat.com> * glib/ghash.c (g_hash_table_foreach): Fix a typo in the docs. (#311569, Ross Burton)
* Make PLT-reduction work with gcc4, and don't include everything inMatthias Clasen2005-03-141-1/+4
| | | | | | | | | | | | | | | | | 2005-03-13 Matthias Clasen <mclasen@redhat.com> Make PLT-reduction work with gcc4, and don't include everything in galias.h: * glib/glib.symbols: Group symbols by header and source file. * glib/makegalias.pl: Protect definitions by the same preprocessor symbols used to guard the headers. Move the alias declarations to a separate file which is produced when calling makegalias.pl -def * glib/Makefile.am (galiasdef.c): Add a rule to generate this file. * glib/*.c: Include galias.h after the other GLib headers, include galiasdef.c at the bottom.
* Implement the same PLT reduction technique used in GTK+:Matthias Clasen2004-09-161-0/+1
| | | | | | Thu Sep 16 02:03:15 2004 Matthias Clasen <maclas@gmx.de> Implement the same PLT reduction technique used in GTK+:
* Point to g_hash_table_lookup_extended() for differentiation betweenMatthias Clasen2004-08-301-1/+4
| | | | | | | | Sun Aug 29 23:58:38 2004 Matthias Clasen <maclas@gmx.de> * glib/ghash.c (g_hash_table_lookup): Point to g_hash_table_lookup_extended() for differentiation between not-found and value-is-NULL. (#150960, Morten Welinder)
* Documentation updates.Matthias Clasen2004-02-271-7/+8
|
* applied patch from #131937 with slight renames. providesTim Janik2004-02-201-0/+34
| | | | | | | Fri Feb 20 03:02:05 2004 Tim Janik <timj@gtk.org> * glib/ghash.[hc]: applied patch from #131937 with slight renames. provides g_hash_table_find().
* Patch from Sven Neumann to make the include order consistent. (#71704)Owen Taylor2002-12-041-3/+1
| | | | | | | Tue Dec 3 20:22:27 2002 Owen Taylor <otaylor@redhat.com> * glib/*.c: Patch from Sven Neumann to make the include order consistent. (#71704)
* Patch from Morten Welinder to make ghash.c properly obeyOwen Taylor2002-11-211-4/+29
| | | | | | | Thu Nov 21 16:19:21 2002 Owen Taylor <otaylor@redhat.com> * glib/ghash.c: Patch from Morten Welinder to make ghash.c properly obey DISABLE_MEM_POOLS. (#96600)
* avoid repeated call of g_spaced_primes_closest() by moving it out of theSven Neumann2002-03-201-3/+3
| | | | | | | | 2002-03-20 Sven Neumann <sven@gimp.org> * glib/ghash.c (g_hash_table_resize): avoid repeated call of g_spaced_primes_closest() by moving it out of the CLAMP macro (spotted by Salmaso Raffaele).
* Minor markup fixes.Matthias Clasen2001-12-161-13/+13
| | | | | | | | * glib/gshell.c, glib/gspawn.c, glib/gspawn-win32.c, glib/gerror.c, glib/gfileutils.c, glib/ghash.c, glib/gmain.c, glib/gasyncqueue.c, glib/gtree.c: Minor markup fixes. * glib/tmpl/caches.sgml: GCs are cached by GTK, not by GDK.
* Documentation fixes.Matthias Clasen2001-12-121-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | * glib/gconvert.c, glib/grand.c, glib/ghash.c, glib/gthreadpool.c, glib/gtree.c: Documentation fixes. * glib/tmpl/allocators.sgml, glib/tmpl/arrays.sgml, glib/tmpl/arrays_byte.sgml, glib/tmpl/arrays_pointer.sgml, glib/tmpl/caches.sgml, glib/tmpl/completion.sgml, glib/tmpl/conversions.sgml, glib/tmpl/datalist.sgml, glib/tmpl/date.sgml, glib/tmpl/error_reporting.sgml, glib/tmpl/fileutils.sgml, glib/tmpl/hash_tables.sgml, glib/tmpl/hooks.sgml, glib/tmpl/macros.sgml, glib/tmpl/macros_misc.sgml, glib/tmpl/main.sgml, glib/tmpl/markup.sgml, glib/tmpl/memory.sgml, glib/tmpl/memory_chunks.sgml, glib/tmpl/messages.sgml, glib/tmpl/misc_utils.sgml, glib/tmpl/modules.sgml, glib/tmpl/numerical.sgml, glib/tmpl/patterns.sgml, glib/tmpl/queue.sgml, glib/tmpl/shell.sgml, glib/tmpl/spawn.sgml, glib/tmpl/string_utils.sgml, glib/tmpl/thread_pools.sgml, glib/tmpl/threads.sgml, glib/tmpl/timers.sgml, glib/tmpl/trees-binary.sgml, glib/tmpl/trees-nary.sgml, glib/tmpl/type_conversion.sgml, glib/tmpl/unicode.sgml, glib/tmpl/warnings.sgml, glib/tmpl/windows.sgml: Improve markup of examples, general consistency improvements.