diff options
author | Automerge script <automerge@asterisk.org> | 2012-11-27 18:20:18 +0000 |
---|---|---|
committer | Automerge script <automerge@asterisk.org> | 2012-11-27 18:20:18 +0000 |
commit | 8c84eb128fe4e250acac1929ab4a4aa687898898 (patch) | |
tree | 2806285e483b7fe7129c49e90d6e9b57c322f01a | |
parent | 37ae4ad43f801be2f573084365beb756be2db7dc (diff) |
Merged revisions 376630 via svnmerge from
file:///srv/subversion/repos/asterisk/trunk
................
r376630 | rmudgett | 2012-11-27 11:54:25 -0600 (Tue, 27 Nov 2012) | 13 lines
Made AST_LIST_REMOVE() simpler and use better names.
* Update doxygen of AST_LIST_REMOVE().
........
Merged revisions 376627 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 376628 from http://svn.asterisk.org/svn/asterisk/branches/10
........
Merged revisions 376629 from http://svn.asterisk.org/svn/asterisk/branches/11
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@376637 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r-- | include/asterisk/linkedlists.h | 60 |
1 files changed, 32 insertions, 28 deletions
diff --git a/include/asterisk/linkedlists.h b/include/asterisk/linkedlists.h index 215df74b8..8715cf1ad 100644 --- a/include/asterisk/linkedlists.h +++ b/include/asterisk/linkedlists.h @@ -848,34 +848,38 @@ struct { \ * \param elm This is a pointer to the entry to be removed. * \param field This is the name of the field (declared using AST_LIST_ENTRY()) * used to link entries of this list together. - * \warning The removed entry is \b not freed nor modified in any way. - */ -#define AST_LIST_REMOVE(head, elm, field) ({ \ - __typeof(elm) __res = NULL; \ - __typeof(elm) __tmp = elm; \ - if (!__tmp) { \ - __res = NULL; \ - } else if ((head)->first == (elm)) { \ - __res = (head)->first; \ - (head)->first = (elm)->field.next; \ - if ((head)->last == (elm)) \ - (head)->last = NULL; \ - } else { \ - typeof(elm) curelm = (head)->first; \ - while (curelm && (curelm->field.next != (elm))) \ - curelm = curelm->field.next; \ - if (curelm) { \ - __res = (elm); \ - curelm->field.next = (elm)->field.next; \ - if ((head)->last == (elm)) \ - (head)->last = curelm; \ - } \ - } \ - if (__res) { \ - (__res)->field.next = NULL; \ - } \ - (__res); \ -}) + * \retval elm if elm was in the list. + * \retval NULL if elm was not in the list or elm was NULL. + * \warning The removed entry is \b not freed. + */ +#define AST_LIST_REMOVE(head, elm, field) \ + ({ \ + __typeof(elm) __elm = (elm); \ + if (__elm) { \ + if ((head)->first == __elm) { \ + (head)->first = __elm->field.next; \ + __elm->field.next = NULL; \ + if ((head)->last == __elm) { \ + (head)->last = NULL; \ + } \ + } else { \ + typeof(elm) __prev = (head)->first; \ + while (__prev && __prev->field.next != __elm) { \ + __prev = __prev->field.next; \ + } \ + if (__prev) { \ + __prev->field.next = __elm->field.next; \ + __elm->field.next = NULL; \ + if ((head)->last == __elm) { \ + (head)->last = __prev; \ + } \ + } else { \ + __elm = NULL; \ + } \ + } \ + } \ + __elm; \ + }) #define AST_RWLIST_REMOVE AST_LIST_REMOVE |