summaryrefslogtreecommitdiff
path: root/lib/vector.c
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2017-01-25 04:13:02 +0100
committerDavid Lamparter <equinox@opensourcerouting.org>2017-01-31 15:28:19 +0100
commit0d9e204694fbdff2ad6c8441ba3008907ddec3db (patch)
treea5dbdc880de9bf68b3cf480b33c6c909594eb741 /lib/vector.c
parent66d29a54a1325217295d19243a5003b65f6ededd (diff)
lib: add vector_unset_value()
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib/vector.c')
-rw-r--r--lib/vector.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/vector.c b/lib/vector.c
index 0b1d5d5046..e16fcf5315 100644
--- a/lib/vector.c
+++ b/lib/vector.c
@@ -165,6 +165,24 @@ vector_unset (vector v, unsigned int i)
}
}
+void
+vector_unset_value (vector v, void *val)
+{
+ size_t i;
+
+ for (i = 0; i < v->active; i++)
+ if (v->index[i] == val)
+ {
+ v->index[i] = NULL;
+ break;
+ }
+
+ if (i + 1 == v->active)
+ do
+ v->active--;
+ while (i && v->index[--i] == NULL);
+}
+
/* Count the number of not emplty slot. */
unsigned int
vector_count (vector v)