diff options
author | Badalyan Vyacheslav <v.badalyan@open-bs.ru> | 2016-10-10 17:59:58 -0400 |
---|---|---|
committer | Badalian Vyacheslav <v.badalyan@open-bs.ru> | 2016-10-11 06:43:34 -0500 |
commit | a884b26392c2199efb8d443f88551e83418e3176 (patch) | |
tree | 4a885f4c8540a39eaab60fcd87cc634cad6db783 /include | |
parent | d75beaa04ab30aed45da2a32a4b1488995484180 (diff) |
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
Diffstat (limited to 'include')
-rw-r--r-- | include/asterisk/vector.h | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/include/asterisk/vector.h b/include/asterisk/vector.h index ef6104d57..4306670e7 100644 --- a/include/asterisk/vector.h +++ b/include/asterisk/vector.h @@ -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; \ } \ |