summaryrefslogtreecommitdiff
path: root/glib/glist.c
Commit message (Collapse)AuthorAgeFilesLines
* glib: Add SPDX license headers automaticallyPhilip Withnall2022-05-181-0/+2
| | | | | | | | | | | | | | Add SPDX license (but not copyright) headers to all files which follow a certain pattern in their existing non-machine-readable header comment. This commit was entirely generated using the command: ``` git ls-files glib/*.[ch] | xargs perl -0777 -pi -e 's/\n \*\n \* This library is free software; you can redistribute it and\/or\n \* modify it under the terms of the GNU Lesser General Public/\n \*\n \* SPDX-License-Identifier: LGPL-2.1-or-later\n \*\n \* This library is free software; you can redistribute it and\/or\n \* modify it under the terms of the GNU Lesser General Public/igs' ``` Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Helps: #1415
* glist: Clarify that g_list_free() and friends only free an entire listPhilip Withnall2020-09-221-2/+2
| | | | | | | | | | They shouldn’t be used to free a list from part-way through, as that is confusing and will leave a dangling pointer from the previous list element. Spotted by Gary Kramlich in !1653. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
* Add some notes on complexity in glib/glist.cEmmanuel Fleury2020-09-021-1/+6
| | | | Related to issue #3
* glist: Add docs examples of how to combine with g_steal_pointer()Philip Withnall2020-02-071-0/+16
| | | | | | | | As suggested by Simon McVittie and triggered by Marco Trevisan. Signed-off-by: Philip Withnall <withnall@endlessm.com> See: https://gitlab.gnome.org/GNOME/glib/merge_requests/818
* list, slist: Add g_clear_{s,}list()Ernestas Kulik2019-11-251-0/+29
| | | | | | | | | | | | | Although not quite as often-occurring, this should help with constructs like this: if (list) { g_list_free_full (list, foo); list = NULL; } Closes https://gitlab.gnome.org/GNOME/glib/issues/1943
* glist: code style cleanup for g_list_insert_before()Christian Hergert2019-05-011-6/+4
| | | | | | This makes the g_list_insert_before() follow more closely the guidelines for GLib, which is to avoid implicit pointer boolean value and to prefer for over while to improve readability.
* list: add g_list_insert_before_link()Christian Hergert2019-05-011-0/+58
| | | | | This adds a new insertion helper using a pre-allocated link which may be advantagous in some situations such as statically linked GList elements.
* glist: Mention -Wcast-function-type problems with g_*list_copy_deep()Philip Withnall2018-08-201-2/+4
| | | | | | Signed-off-by: Philip Withnall <withnall@endlessm.com> https://gitlab.gnome.org/GNOME/glib/issues/1492
* glib: document restrictions on various foreach() functionsDan Winship2017-11-161-0/+6
| | | | | | | | Some foreach() functions allow you to modify the object they are iterating, and others don't, but the docs were not generally clear about this. https://bugzilla.gnome.org/show_bug.cgi?id=724383
* GList: Fix typo of member ->prev in documentationDaniel Boles2017-08-071-1/+1
| | | | It said list->previous, which is not a thing that exists.
* glib/: LGPLv2+ -> LGPLv2.1+Sébastien Wilmet2017-05-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All glib/*.{c,h} files have been processed, as well as gtester-report. 12 of those files are not licensed under LGPL: gbsearcharray.h gconstructor.h glibintl.h gmirroringtable.h gscripttable.h gtranslit-data.h gunibreak.h gunichartables.h gunicomp.h gunidecomp.h valgrind.h win_iconv.c Some of them are generated files, some are licensed under a BSD-style license and win_iconv.c is in the public domain. Sub-directories inside glib/: deprecated/: processed in a previous commit glib-mirroring-tab/: already LGPLv2.1+ gnulib/: not modified, the code is copied from gnulib libcharset/: a copy pcre/: a copy tests/: processed in a previous commit https://bugzilla.gnome.org/show_bug.cgi?id=776504
* glist: Clarify that g_list_nth() is expensivePhilip Withnall2015-03-031-0/+8
| | | | | | | | | Just in case people have forgotten their basic algorithms course. Seen in some pretty terrible code in the wild; hopefully mentioning the cost in the documentation will make people think twice about using a counter variable when iterating over a linked list. https://bugzilla.gnome.org/show_bug.cgi?id=741779
* glist: Clarify how g_list_free_1() handles linksPhilip Withnall2015-03-031-1/+4
| | | | | | It doesn’t, which is fine, but could be unexpected if undocumented. https://bugzilla.gnome.org/show_bug.cgi?id=741779
* glist: Mention that g_list_length() is bad for checking list emptinessPhilip Withnall2015-02-111-1/+2
| | | | | | | | | | | | | | Despite linked lists being a fairly fundamental computer science concept, some developers insist on using: g_list_length (list) > 0 to determine whether a list is non-empty, rather than using: list != NULL Add a comment to the documentation for g_list_length() and g_slist_length() pointing out the better alternative in the hope that it will prevent some of this abuse. https://bugzilla.gnome.org/show_bug.cgi?id=741024
* docs: let go of &ast;Matthias Clasen2014-02-141-6/+6
| | | | | | Since we are no longer using sgml mode, using /&ast; &ast;/ to escape block comments inside examples does not work anymore. Switch to using line comments with //
* Docs: Drop entities, switch away from sgml modeMatthias Clasen2014-02-091-2/+2
| | | | | | | | | | Since all element markup is now gone from the doc comments, we can turn off the gtk-doc sgml mode, which means that from now on, docbook markup is no longer allowed in doc comments. To make this possible, we have to replace all remaining entities in doc comments by their replacement text, &amp; -> & and so on.
* Eradicate links and xrefsMatthias Clasen2014-02-081-12/+9
| | | | These are all replaced by markdown ref links.
* Annotate all examples with their languageMatthias Clasen2014-02-011-8/+8
| | | | The C ones, at least.
* Docs: Don't use the note tagMatthias Clasen2014-01-311-22/+9
| | | | More markup avoidance.
* Updated FSF's addressDaniel Mustieles2014-01-311-3/+1
|
* GList: Some further documentation and formatting tweaksMatthias Clasen2014-01-191-224/+235
|
* tag: documentation enhancement for novice application developersOlivier Sessink2014-01-191-51/+113
| | | | | | | | | | | Adds some code examples how functions can be used. Adds a hint to look at GQueue if access to the start and the end of the list is required. applying comments from Emmanuele Bassi and adds some more improvements to clarify how functions should be used. https://bugzilla.gnome.org/show_bug.cgi?id=683388
* Make GList more robustMatthias Clasen2013-03-011-0/+3
| | | | | | g_list_delete_link was silently ignoring a NULL link before the last change. Make it do so again, since we've found callers that rely on this.
* GList: be more robustMatthias Clasen2013-02-241-34/+35
| | | | | | | | | We can detect list corruption in some cases. The new test case demonstrates a case where we can warn instead of silently corrupt the list. This was pointed out by Steve Grubb. Also, use the same auxiliary routine in all places where we unlink a list element.
* Use "Returns:" instead of the invalid "@returns" for annotating return values.Robert Ancell2012-11-011-8/+13
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=673229
* Adds g_list_copy_deep and g_slist_copy_deepJonh Wendell2012-06-211-3/+45
| | | | | | | | | | | | They make a full (deep) copy of a list. In contrast with g_[s]list_copy(), these functions take a function as a argument to make a copy of each list element, in addition to copying the list container itself. The functions g_[s]list_copy() were reimplemented to just call the new functions with NULL as the function argument, which will behave like current implementation. https://bugzilla.gnome.org/show_bug.cgi?id=675024
* Document that g_list_sort is a stable sort.Josselin Mouette2011-11-201-1/+2
| | | | | | This is a guarantee for the future so that applications can rely on it. https://bugzilla.gnome.org/show_bug.cgi?id=531973
* More consistent doc formattingMatthias Clasen2011-11-121-3/+1
| | | | | Move some things around, make capitalization of short descriptions more consistent.
* Remove bits of dead code identified by coverage testsMatthias Clasen2011-10-031-10/+6
| | | | | These lines could were not hit by our tests, and examination of the code reveals that they can't ever be hit.
* Don't #include <glib/gslice.h> from gmem.hRyan Lortie2011-09-181-0/+1
| | | | | | 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.
* Move GAllocator/GMemChunk to separate fileRyan Lortie2011-09-181-33/+0
| | | | | | | | | Create a deprecated/ directory that we can start moving ancient chunks of code to. Start with GAllocator, GMemChunk and related APIs. Also drop all mention of them from the docs. https://bugzilla.gnome.org/show_bug.cgi?id=659427
* Revert "Optimize g_[s]list_free_full a bit"Matthias Clasen2011-07-271-8/+3
| | | | | | | This reverts commit 98b667d052b1274f80b8898a32d0753e9e2e5c1a. The commit was not actually an optimization, since g_list_free is pretty smart.
* Optimize g_[s]list_free_full a bitMatthias Clasen2011-07-101-3/+8
| | | | | | No need to iterate the list twice. Proposed by Luiz Augusto von Dentz, http://bugzilla.gnome.org/show_bug.cgi?id=653935
* Documentation fixupsMatthias Clasen2011-05-291-1/+1
|
* Correct gtk-doc SECTION: syntaxJohan Dahlin2011-02-011-1/+1
| | | | | g-ir-scanner does not allow a space between the : and the section name.
* Bug 158725 - free linked list with dataRyan Lortie2010-10-281-1/+20
| | | | | | | | | Add some helpers for freeing a linked list along with its elements by providing a GDestroyNotify to call on each of them. Add a test. Based on a patch from Cosimo Cecchi.
* Remove excessive header inclusionsMatthias Clasen2010-09-031-3/+5
|
* glib/: fully remove galias hacksRyan Lortie2010-07-071-4/+0
|
* GList, GSList: move docs from tmpl to .cRyan Lortie2010-02-011-0/+154
|
* Tiny doc fixMatthias Clasen2008-06-121-1/+1
| | | | svn path=/trunk/; revision=7023
* Fix the docsMatthias Clasen2008-04-031-1/+1
| | | | svn path=/trunk/; revision=6810
* fix last commit.Benjamin Otte2008-03-011-1/+1
| | | | | | | | | | 2008-03-01 Benjamin Otte <otte@gnome.org> * glib/glist.c: fix last commit. svn path=/trunk/; revision=6609
* Move docs inlineMatthias Clasen2008-02-291-7/+354
| | | | svn path=/trunk/; revision=6607
* use standard_calloc to allocate the profile_data. (#335209, Chris Wilson)Matthias Clasen2006-03-201-24/+27
| | | | | | | | | | | | | | | | | | 2006-03-20 Matthias Clasen <mclasen@redhat.com> * glib/gmem.c (profiler_log): use standard_calloc to allocate the profile_data. (#335209, Chris Wilson) * glib/gmain.c (g_main_context_unref): Avoid a deadlock. (#335207, Chris Wilson) Minor optimizations (#335216, Chris Wilson): * glib/gasyncqueue.c (g_async_queue_pop_intern_unlocked): Use g_queue_peek_tail_link instead of g_queue_peek_tail. * glib/glist.c: * glib/gslist.c: Avoid some memset calls.
* - Added g_list_insert_sorted_with_data () andMartyn James Russell2005-12-071-19/+31
| | | | | | | | | | | | * docs/reference/glib/glib-sections.txt: * docs/reference/glib/tmpl/linked_lists_double.sgml: * docs/reference/glib/tmpl/linked_lists_single.sgml: * glib/glist.[ch]: * glib/gslist.[ch]: - Added g_list_insert_sorted_with_data () and g_slist_insert_sorted_with_data (). - Removed the extra check in g_list_sort() and g_slist_sort() for GCompareDataFunc vs. GCompareFunc.
* implement chain walking for arbitrary ->next pointer offsets inTim Janik2005-12-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | Mon Dec 5 15:53:20 2005 Tim Janik <timj@imendio.com> * glib/gslice.c: implement chain walking for arbitrary ->next pointer offsets in g_slice_free_chain_with_offset() based on a patch by behdad in bug 323178. moved time consuming logic from g_slice_free() out of the inner loop, so g_slice_free_chain_with_offset() provides a real performance benefit over g_slice_free1() now. * glib/gslice.h: renamed g_slice_free_chain() to g_slice_free_chain_with_offset(). implemented g_slice_free_chain() as a type-safe macro as suggested in bug 323178. simplified the macro implementation of g_slice_free() and implemented it in a type safe manner for all compliers as suggested by Morten Welinder <mortenw@gnome.org>. * glib/gmain.c: * glib/glist.c: * glib/gslist.c: * glib/glib.symbols: s/g_slice_free_chain/g_slice_free_chain_with_offset/
* Apply a patch from Behdad Esfahbod to use a faster lookup table forMatthias Clasen2005-11-041-6/+3
| | | | | | | | | | | | | | | 2005-11-04 Matthias Clasen <mclasen@redhat.com> * glib/Makefile.am: Apply a patch from Behdad Esfahbod to use a faster lookup table for g_unichar_get_mirror_char(). * glib/gmirroringtable.h: The new table. * glib/gunichartables.h: Remove bidi_mirroring_table. * glib/gen-unicode-tables.pl: Don't generate the mirroring table. * glib/glib-mirroring-tab/*: Sources for the program which generated gmirroringtable.h. * glib/glist.c: Avoid some code duplication.
* prepared deprecation of GMemChunk and GAllocator. added g_slice_*() API toTim Janik2005-11-011-195/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Make PLT-reduction work with gcc4, and don't include everything inMatthias Clasen2005-03-141-1/+3
| | | | | | | | | | | | | | | | | 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+: