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
This commit is contained in:
parent
3ab7fae96b
commit
17031f12fe
1 changed files with 9 additions and 5 deletions
|
@ -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; \
|
||||
} \
|
||||
|
|
Loading…
Reference in a new issue