summaryrefslogtreecommitdiff
path: root/lib/linklist.c
AgeCommit message (Collapse)Author
2023-02-09*: auto-convert to SPDX License IDsDavid Lamparter
Done with a combination of regex'ing and banging my head against a wall. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-12-09lib: Hide list macros in linklist.cDonald Sharp
The LISTNODE_ATTACH|DELETE macros are only used in linklist.c. Let's remove temptation from people to use them. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-11-04lib: When adding to front of list ensure we handle tail toDonald Sharp
When inserting to the front of a list with listnode_add_head if the list is empty, the tail will not be properly set and subsuquent calls to insert/remove will cause the function to crash. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-05-12lib: add one check in "list_sort()"anlan_cs
Add one check in `list_sort()`: Immediatly return if no any items in this list. Signed-off-by: anlan_cs <vic.lan@pica8.com>
2021-05-03lib: kill unused list_filter_out_nodes()David Lamparter
pimd was the only user of this function, and that has gone away now. So just kill the function. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-03-17*: require semicolon after DEFINE_MTYPE & coDavid Lamparter
Back when I put this together in 2015, ISO C11 was still reasonably new and we couldn't require it just yet. Without ISO C11, there is no "good" way (only bad hacks) to require a semicolon after a macro that ends with a function definition. And if you added one anyway, you'd get "spurious semicolon" warnings on some compilers... With C11, `_Static_assert()` at the end of a macro will make it so that the semicolon is properly required, consumed, and not warned about. Consistently requiring semicolons after "file-level" macros matches Linux kernel coding style and helps some editors against mis-syntax'ing these macros. Signed-off-by: David Lamparter <equinox@diac24.net>
2020-10-23lib, bgpd: convert lttng tracepoints to frrtrace()Quentin Young
- tracepoint() -> frrtrace() - tracelog() -> frrtracelog() - tracepoint_enabled() -> frrtrace_enabled() Also removes copypasta'd #ifdefs for those LTTng macros, those are handled in lib/trace.h Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-10-23lib: move trace.h -> libfrr_trace.hQuentin Young
Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-10-23lib: add tracepoints for *malloc, list opsQuentin Young
- Add tracepoints for FRR malloc and free - Add tracepoints for basic list operations Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-08-11lib: introduce new list_dup() APIRenato Westphal
This new function will be used by the upcoming TI-LFA code. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-08-05lib: allow listnode memory to be managed by the appAnuradha Karuppiah
In most cases this memory is pre-allocated along with the base element. Similarly it is stored in the base element to allow efficient del without lookup (main reason for using DLL vs. SLL). So (in most cases) there should be no need to manage the element/data and listnode memories separately. Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2019-12-14lib/linklist: flip the bitrot compostDavid Lamparter
The whole lib/linklist.c code shouldn't really be used for new code (the lib/typesafe.h bits are better.) So, a new need for these unused functions shouldn't be coming up. Signed-off-by: David Lamparter <equinox@diac24.net>
2019-05-28lib: const a couple linklist apisQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-28Merge pull request #4239 from sarav511/rpJafar Al-Gharaibeh
pimd: PIM Bootstrap Message Processing
2019-05-17lib: add list_to_arrayQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-14lib: implement utility function API which does the followingsaravanank
1. listnode_add_sort_nodup - This API adds to list only if no duplicate element available in the list. returns true/false 2. list_filter_out_nodes - This API deletes the nodes which satisfy the given condition. condition is passed as a func ptr in API. This function takes in node data(void ptr). Signed-off-by: Saravanan K <saravanank@vmware.com>
2019-04-22lib: fix warning in linklist apiMark Stapp
Add return value and comment to new/recent linklist api to clean up compile warning. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-04-20lib: return listnode on add for subsequent efficent delAnuradha Karuppiah
Having to lookup the DLL node to delete it defeats one purpose of using DLLs. Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2019-03-29lib: add listnode_add_force utility routinePhilippe Guibert
that routine does the same as listnode_add; in addition it creates the linked list if needed. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-03-29lib: add lookup utility routine that accepts null list valuesPhilippe Guibert
lists passed as parameter that are null, are accepted by the function. I would even propose to silently return NULL in official listnode_lookup() routine. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-10-02*: list_delete_and_null() -> list_delete()David Lamparter
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-10-02lib: remove deprecated list_delete()/list_free()David Lamparter
Deprecation time has passed. Signed-off-by: David Lamparter <equinox@diac24.net>
2018-09-12lib vtysh zebra: variable shadowing fixesF. Aragon
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-08-13lib: add listnode_add_head()Renato Westphal
Provide a new convenience function that adds an element to the beginning of a list. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-06-29bgpd: null check (Coverity 1453455)F. Aragon
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-05-25lib: add proper doc comments for hash & linklistQuentin Young
* Remove references to ospf source files from linklist.[ch] * Remove documentation comments from hash.c and linklist.c * Add comprehensive documentation comments to linklist.h and hash.h Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-05-25lib: add list_sort(), list_dup()Quentin Young
* list_dup(): duplicates a linked list * list_sort(): in-place sort of linked list w/ ascending quicksort Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-10-05*: Convert list_free usage to list_deleteDonald Sharp
list_free is occassionally being used to delete the list and accidently not deleting all the nodes. We keep running across this usage pattern. Let's remove the temptation and only allow list_delete to handle list deletion. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-05*: Convert list_delete(struct list *) to ** to allow nullingDonald Sharp
Convert the list_delete(struct list *) function to use struct list **. This is to allow the list pointer to be nulled. I keep running into uses of this list_delete function where we forget to set the returned pointer to NULL and attempt to use it and then experience a crash, usually after the developer has long since left the building. Let's make the api explicit in it setting the list pointer to null. Cynical Prediction: This code will expose a attempt to use the NULL'ed list pointer in some obscure bit of code. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-07-17*: reindentreindent-master-afterwhitespace / reindent
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'` Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-05-15*: make consistent & update GPLv2 file headersDavid Lamparter
The FSF's address changed, and we had a mixture of comment styles for the GPL file header. (The style with * at the beginning won out with 580 to 141 in existing files.) Note: I've intentionally left intact other "variations" of the copyright header, e.g. whether it says "Zebra", "Quagga", "FRR", or nothing. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-09-19*: split & distribute memtypes and stop (re|ab)using lib/ MTYPEsDavid Lamparter
This is a rather large mechanical commit that splits up the memory types defined in lib/memtypes.c and distributes them into *_memory.[ch] files in the individual daemons. The zebra change is slightly annoying because there is no nice place to put the #include "zebra_memory.h" statement. bgpd, ospf6d, isisd and some tests were reusing MTYPEs defined in the library for its own use. This is bad practice and would break when the memtype are made static. Acked-by: Vincent JARDIN <vincent.jardin@6wind.com> Acked-by: Donald Sharp <sharpd@cumulusnetworks.com> [CF: rebased for cmaster-next] Signed-off-by: David Lamparter <equinox@opensourcerouting.org> Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2016-07-28lib: linklist: clean up insert-before/after dupsDavid Lamparter
- list_add_node_next was in fact unused - list_add_node_prev performs a subset of listnode_add_before and its only use in isisd replaced with that. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-07-28lib: linklist: add listnode_add_before()David Lamparter
This utility function, to join the zoo that the Quagga linked-list implementation has accumulated, does an insert-before while returning the newly allocated node. It is similar to: - listnode_add_after(), but - complementary direction - returns allocated node - list_add_node_prev(), but - supports before == NULL - returns allocated node In general, the entire linked-list implementation is in bad shape, and while it needs a cleanup / rewrite / replacement, this would both cause significant conflicts and block other cleanups... Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-05-29ospfd: Tweak previous iface RR write patch to avoid free/malloc & redundant logPaul Jakma
* linklist.{c,h}: (listnode_move_to_tail) new unction to move a listnode to tail of list. * ospf_packet.c: (ospf_write) remove debug that seemed to be mostly covered by existing debug. Use listnode_move_to_tail to just move the list node to the end of the tail, rather than freeing the one to hand and allocing a new one.
2014-06-04*: nuke ^L (page feed)David Lamparter
Quagga sources have inherited a slew of Page Feed (^L, \xC) characters from ancient history. Among other things, these break patchwork's XML-RPC API because \xC is not a valid character in XML documents. Nuke them from high orbit. Patches can be adapted simply by: sed -e 's%^L%%' -i filename.patch (you can type page feeds in some environments with Ctrl-V Ctrl-L) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2009-06-12[cleanup] Convert XMALLOC/memset to XCALLOCStephen Hemminger
Simple conversion of XMALLOC/memset to XCALLOC
2008-02-28[lib/linklist] Enforce "nodes must have data" invariant more rigorouslyPaul Jakma
2008-02-28 Paul Jakma <paul.jakma@sun.com> * linklist.c: This implementation expects that the data pointer not be null, e.g. listgetdata() asserts this. The list add methods don't apply the same sanity check. Noted by Jim Carlson in bug #437.
2007-11-12+ fixed bug #418 (changing address on an existing interface doesn't cause ↵Denis Ovsienko
existing static routes to be revalidated)
2006-06-15[lib] list_delete shouldn't duplicate list_delete_all_nodePaul Jakma
2006-06-15 Paul Jakma <paul.jakma@sun.com> * linklist.c: (list_delete) call list_delete_all_node, don't duplicate it.
2005-05-062005-05-06 Paul Jakma <paul@dishone.st>paul
* (general) extern and static'ification of functions in code and header. Cleanup any definitions with unspecified arguments. Add casts for callback assignments where the callback is defined, typically, as passing void *, but the function being assigned has some other pointer type defined as its argument, as gcc complains about casts from void * to X* via function arguments. Fix some old K&R style function argument definitions. Add noreturn gcc attribute to some functions, as appropriate. Add unused gcc attribute to some functions (eg ones meant to help while debugging) Add guard defines to headers which were missing them. * command.c: (install_node) add const qualifier, still doesnt shut up the warning though, because of the double pointer. (cmp_node) ditto * keychain.c: (key_str2time) Add GET_LONG_RANGE() macro, derived fromn vty.h ones to fix some of the (long) < 0 warnings. * thread.c: (various) use thread_empty (cpu_record_hash_key) should cast to uintptr_t, a stdint.h type * vty.h: Add VTY_GET_IPV4_ADDRESS and VTY_GET_IPV4_PREFIX so they removed from ospfd/ospf_vty.h * zebra.h: Move definition of ZEBRA_PORT to here, to remove dependence of lib on zebra/zserv.h
2005-04-072005-04-07 Paul Jakma <paul.jakma@sun.com>paul
* (global): Fix up list loops to match changes in lib/linklist, and some basic auditing of usage. * configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES * HACKING: Add notes about deprecating interfaces and commands. * lib/linklist.h: Add usage comments. Rename getdata macro to listgetdata. Rename nextnode to listnextnode and fix its odd behaviour to be less dangerous. Make listgetdata macro assert node is not null, NULL list entries should be bug condition. ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use with for loop, Suggested by Jim Carlson of Sun. Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the "safety" of previous macro. LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to distinguish from the similarly named functions, and reflect their effect better. Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section with the old defines which were modified above, for backwards compatibility - guarded to prevent Quagga using it.. * lib/linklist.c: fix up for linklist.h changes. * ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single scan of the area list, rather than scanning all areas first for INTER_ROUTER and then again for INTER_NETWORK. According to 16.2, the scan should be area specific anyway, and further ospf6d does not seem to implement 16.3 anyway.
2004-09-23Remove usage of evil list and listnode typedefs.hasso
2003-12-22Revert my "microfix". It was caused by misreading code. Gilad is right ashasso
always.
2003-12-22note that order of = items is undefined, probablygdt
2003-12-22add comments clarifying the operation of listnode_add_sortgdt
2003-12-21lib/if.c part from [quagga-dev 552] and lib/inklist.c part from [quagga-devhasso
555]. Okayed by Paul.
2003-09-232003-09-24 sowmini.varadhan@sun.compaul
* lib/linklist.c: (if_cmp_func) Fix handling of case where list->cmp returns 0.
2002-12-13 Kevin C Miller <kevinm@andrew.cmu.edu>paul
[zebra 16681] OSPF NSSA Patches
2002-12-13Initial revisionpaul