Skip to content
Snippets Groups Projects
Commit 17031f12 authored by Badalyan Vyacheslav's avatar Badalyan Vyacheslav
Browse files

vector: After remove element recheck index

Small fix. It is necessary to double-check
the index that we just removed because there
is a new element.

ASTERISK-26453 #close

Change-Id: Ib947fa94dc91dcd9341f357f1084782c64434eb7
parent 3ab7fae9
No related branches found
No related tags found
No related merge requests found
......@@ -367,11 +367,13 @@
int count = 0; \
size_t idx; \
typeof(value) __value = (value); \
for (idx = 0; idx < (vec)->current; ++idx) { \
for (idx = 0; idx < (vec)->current; ) { \
if (cmp((vec)->elems[idx], __value)) { \
cleanup((vec)->elems[idx]); \
AST_VECTOR_REMOVE_UNORDERED((vec), idx); \
++count; \
} else { \
++idx; \
} \
} \
count; \
......@@ -417,14 +419,16 @@
int count = 0; \
size_t idx; \
typeof(value) __value = (value); \
for (idx = 0; idx < (vec)->current; ++idx) { \
for (idx = 0; idx < (vec)->current; ) { \
if (cmp((vec)->elems[idx], __value)) { \
cleanup((vec)->elems[idx]); \
AST_VECTOR_REMOVE_ORDERED((vec), idx); \
AST_VECTOR_REMOVE_ORDERED((vec), idx); \
++count; \
} else { \
++idx; \
} \
} \
oount; \
count; \
})
/*!
......@@ -445,7 +449,7 @@
for (idx = 0; idx < (vec)->current; ++idx) { \
if (cmp((vec)->elems[idx], __value)) { \
cleanup((vec)->elems[idx]); \
AST_VECTOR_REMOVE_ORDERED((vec), idx); \
AST_VECTOR_REMOVE_ORDERED((vec), idx); \
res = 0; \
break; \
} \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment