summaryrefslogtreecommitdiff
path: root/lib/vector.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/vector.c')
-rw-r--r--lib/vector.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/lib/vector.c b/lib/vector.c
index 03ad3171d6..e16fcf5315 100644
--- a/lib/vector.c
+++ b/lib/vector.c
@@ -25,7 +25,7 @@
#include "memory.h"
DEFINE_MTYPE_STATIC(LIB, VECTOR, "Vector")
-DEFINE_MTYPE( LIB, VECTOR_INDEX, "Vector index")
+DEFINE_MTYPE_STATIC(LIB, VECTOR_INDEX, "Vector index")
/* Initialize vector : allocate memory and return vector. */
vector
@@ -44,18 +44,6 @@ vector_init (unsigned int size)
}
void
-vector_only_wrapper_free (vector v)
-{
- XFREE (MTYPE_VECTOR, v);
-}
-
-void
-vector_only_index_free (void *index)
-{
- XFREE (MTYPE_VECTOR_INDEX, index);
-}
-
-void
vector_free (vector v)
{
XFREE (MTYPE_VECTOR_INDEX, v->index);
@@ -177,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)