for (unsigned int i = 0; i < vector_active(result); i++) {
if (strlen(vector_slot(result, i)) == 0) {
XFREE(MTYPE_TMP, vector_slot(result, i));
- vector_unset(result, i);
+ vector_remove(result, i);
+ --i;
}
}
return result;
return node;
}
-static void vector_remove(vector v, unsigned int ix)
+static void graph_vector_remove(vector v, unsigned int ix)
{
if (ix >= v->active)
return;
// remove node from graph->nodes
for (unsigned int i = vector_active(graph->nodes); i--; /**/)
if (vector_slot(graph->nodes, i) == node) {
- vector_remove(graph->nodes, i);
+ graph_vector_remove(graph->nodes, i);
break;
}
// remove from from to->from
for (unsigned int i = vector_active(to->from); i--; /**/)
if (vector_slot(to->from, i) == from) {
- vector_remove(to->from, i);
+ graph_vector_remove(to->from, i);
break;
}
// remove to from from->to
for (unsigned int i = vector_active(from->to); i--; /**/)
if (vector_slot(from->to, i) == to) {
- vector_remove(from->to, i);
+ graph_vector_remove(from->to, i);
break;
}
}
}
}
+void vector_remove(vector v, unsigned int ix)
+{
+ if (ix >= v->active)
+ return;
+
+ int n = (--v->active) - ix;
+
+ memmove(&v->index[ix], &v->index[ix + 1], n * sizeof(void *));
+ v->index[v->active] = NULL;
+}
+
void vector_unset_value(vector v, void *val)
{
size_t i;
extern int vector_set_index(vector v, unsigned int i, void *val);
extern void vector_unset(vector v, unsigned int i);
extern void vector_unset_value(vector v, void *val);
+extern void vector_remove(vector v, unsigned int ix);
extern unsigned int vector_count(vector v);
extern void vector_free(vector v);