summaryrefslogtreecommitdiffstats
path: root/lib/vector.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* *: auto-convert to SPDX License IDsDavid Lamparter2023-02-091-16/+1
| | | | | | Done with a combination of regex'ing and banging my head against a wall. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib: remove `vector_get_index()`David Lamparter2021-11-081-11/+0
| | | | | | | ... its only purpose was to serve as a footgun, and all such uses have been eliminated now. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib: keep element count in vector codeDavid Lamparter2021-10-181-13/+20
| | | | | | | | ... to speed up vector_empty_slot() among other things. Behavior should be 100% identical to previous. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib: fix incorrect thread managementIgor Ryzhov2021-10-061-0/+11
| | | | | | | | | | | The current code passes an address of a local variable to `thread_add_read` which stores it into `thread->ref` by the lib. The next time the thread callback is executed, the lib stores NULL into the `thread->ref` which means it writes into some random memory on the stack. To fix this, we should pass a pointer to the vector entry to the lib. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* *: 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: add vector_compact(), use after str splitsQuentin Young2018-06-061-0/+10
| | | | | | | | | * Add function to move all data to the start of a vector by shifting over contiguous empty slots * Use this function to remove empty slots leftover after frrstr_filter_vec Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* lib: add vector_remove() to vector.[ch]Quentin Young2018-06-061-0/+11
| | | | | | | | | | | An optimized version of this has already been implemented within graph.c that assumes some specialized constraints for that code. It's generally useful so this change implements a general purpose version of it. This fixes cmd_make_strvec() that was broken by some code shuffling in previous commits. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* *: style for | supportQuentin Young2018-06-061-0/+1
| | | | Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* lib: add string utilitiesQuentin Young2018-06-061-0/+15
| | | | | | | | I see lots of the same code being copy-pasted and slightly tweaked for string processing all over the codebase. Time to start aggregating these pieces into something consistent and correct. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* *: reindentreindent-master-afterwhitespace / reindent2017-07-171-105/+91
| | | | | | 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>
* lib: add vector_unset_value()David Lamparter2017-01-311-0/+18
| | | | Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib: clean up tab-completion memory countingDavid Lamparter2017-01-311-13/+1
| | | | 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>
* 2005-03-14 Paul Jakma <paul.jakma@sun.com>paul2005-03-141-13/+13
| | | | | | | | | | * (global) update all c files to match the lib/vector.h rename of (struct vector).active to max, and vector_max macro to vector_active. * lib/vector.h: Rename to (struct vector).max to slightly less confusing active, for the number of active slots, distinct from allocated or active-and-not-empty. Rename vector_max to vector_active for same reason.
* Initial revisionpaul2002-12-131-0/+189