summaryrefslogtreecommitdiffstats
path: root/lib/linklist.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* lib: kill unused list_filter_out_nodes()David Lamparter2021-05-031-17/+0
| | | | | | | 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>
* *: require semicolon after DEFINE_MTYPE & coDavid Lamparter2021-03-171-2/+2
| | | | | | | | | | | | | | | | | 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>
* lib, bgpd: convert lttng tracepoints to frrtrace()Quentin Young2020-10-231-4/+4
| | | | | | | | | | | - 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>
* lib: move trace.h -> libfrr_trace.hQuentin Young2020-10-231-1/+1
| | | | Signed-off-by: Quentin Young <qlyoung@nvidia.com>
* lib: add tracepoints for *malloc, list opsQuentin Young2020-10-231-0/+9
| | | | | | | - Add tracepoints for FRR malloc and free - Add tracepoints for basic list operations Signed-off-by: Quentin Young <qlyoung@nvidia.com>
* lib: introduce new list_dup() APIRenato Westphal2020-08-121-0/+17
| | | | | | This new function will be used by the upcoming TI-LFA code. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* lib: allow listnode memory to be managed by the appAnuradha Karuppiah2020-08-051-21/+37
| | | | | | | | | | | 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>
* lib/linklist: flip the bitrot compostDavid Lamparter2019-12-141-23/+0
| | | | | | | | 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>
* lib: const a couple linklist apisQuentin Young2019-05-281-2/+2
| | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* Merge pull request #4239 from sarav511/rpJafar Al-Gharaibeh2019-05-281-0/+57
|\ | | | | pimd: PIM Bootstrap Message Processing
| * lib: implement utility function API which does the followingsaravanank2019-05-151-0/+57
| | | | | | | | | | | | | | | | | | | | 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>
* | lib: add list_to_arrayQuentin Young2019-05-171-0/+15
|/ | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* lib: fix warning in linklist apiMark Stapp2019-04-221-1/+1
| | | | | | | Add return value and comment to new/recent linklist api to clean up compile warning. Signed-off-by: Mark Stapp <mjs@voltanet.io>
* lib: return listnode on add for subsequent efficent delAnuradha Karuppiah2019-04-201-1/+3
| | | | | | | Having to lookup the DLL node to delete it defeats one purpose of using DLLs. Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
* lib: add listnode_add_force utility routinePhilippe Guibert2019-03-291-0/+7
| | | | | | | 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>
* lib: add lookup utility routine that accepts null list valuesPhilippe Guibert2019-03-291-0/+7
| | | | | | | | 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>
* *: list_delete_and_null() -> list_delete()David Lamparter2018-10-021-1/+1
| | | | Signed-off-by: David Lamparter <equinox@diac24.net>
* lib: remove deprecated list_delete()/list_free()David Lamparter2018-10-021-5/+0
| | | | | | Deprecation time has passed. Signed-off-by: David Lamparter <equinox@diac24.net>
* lib vtysh zebra: variable shadowing fixesF. Aragon2018-09-121-2/+2
| | | | Signed-off-by: F. Aragon <paco@voltanet.io>
* lib: add listnode_add_head()Renato Westphal2018-08-131-0/+20
| | | | | | | Provide a new convenience function that adds an element to the beginning of a list. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* bgpd: null check (Coverity 1453455)F. Aragon2018-06-291-19/+3
| | | | Signed-off-by: F. Aragon <paco@voltanet.io>
* lib: add proper doc comments for hash & linklistQuentin Young2018-05-251-23/+7
| | | | | | | | * 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>
* lib: add list_sort(), list_dup()Quentin Young2018-05-251-0/+39
| | | | | | | * 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>
* *: Convert list_free usage to list_deleteDonald Sharp2017-10-051-2/+2
| | | | | | | | | | 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>
* *: Convert list_delete(struct list *) to ** to allow nullingDonald Sharp2017-10-051-5/+11
| | | | | | | | | | | | | | | | | | | 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>
* *: reindentreindent-master-afterwhitespace / reindent2017-07-171-215/+189
| | | | | | indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'` Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* *: make consistent & update GPLv2 file headersDavid Lamparter2017-05-151-4/+3
| | | | | | | | | | | 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>
* *: split & distribute memtypes and stop (re|ab)using lib/ MTYPEsDavid Lamparter2016-09-191-0/+3
| | | | | | | | | | | | | | | | | | | 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>
* lib: linklist: clean up insert-before/after dupsDavid Lamparter2016-07-281-47/+2
| | | | | | | | - 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>
* lib: linklist: add listnode_add_before()David Lamparter2016-07-281-0/+38
| | | | | | | | | | | | | | | | | | | | 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>
* ospfd: Tweak previous iface RR write patch to avoid free/malloc & redundant logPaul Jakma2016-05-301-0/+7
| | | | | | | | | * 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.
* *: nuke ^L (page feed)David Lamparter2014-06-041-4/+4
| | | | | | | | | | | | | | 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>
* [cleanup] Convert XMALLOC/memset to XCALLOCStephen Hemminger2009-06-121-10/+2
| | | | Simple conversion of XMALLOC/memset to XCALLOC
* [lib/linklist] Enforce "nodes must have data" invariant more rigorouslyPaul Jakma2008-02-281-5/+15
| | | | | | | | | | 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.
* + fixed bug #418 (changing address on an existing interface doesn't cause ↵Denis Ovsienko2007-11-121-0/+1
| | | | existing static routes to be revalidated)
* [lib] list_delete shouldn't duplicate list_delete_all_nodePaul Jakma2006-06-151-10/+1
| | | | | | | 2006-06-15 Paul Jakma <paul.jakma@sun.com> * linklist.c: (list_delete) call list_delete_all_node, don't duplicate it.
* 2005-05-06 Paul Jakma <paul@dishone.st>paul2005-05-061-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | * (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-07 Paul Jakma <paul.jakma@sun.com>paul2005-04-071-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * (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.
* Remove usage of evil list and listnode typedefs.hasso2004-09-231-4/+4
|
* Revert my "microfix". It was caused by misreading code. Gilad is right ashasso2003-12-221-6/+1
| | | | always.
* note that order of = items is undefined, probablygdt2003-12-221-0/+4
|
* add comments clarifying the operation of listnode_add_sortgdt2003-12-221-1/+7
|
* lib/if.c part from [quagga-dev 552] and lib/inklist.c part from [quagga-devhasso2003-12-211-7/+3
| | | | 555]. Okayed by Paul.
* 2003-09-24 sowmini.varadhan@sun.compaul2003-09-241-2/+6
| | | | | * lib/linklist.c: (if_cmp_func) Fix handling of case where list->cmp returns 0.
* Kevin C Miller <kevinm@andrew.cmu.edu>paul2002-12-131-0/+5
| | | | [zebra 16681] OSPF NSSA Patches
* Initial revisionpaul2002-12-131-0/+312