[asterisk-commits] rmudgett: branch 10 r376628 - in /branches/10: ./ include/asterisk/linkedlists.h
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Nov 27 11:35:57 CST 2012
Author: rmudgett
Date: Tue Nov 27 11:35:54 2012
New Revision: 376628
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=376628
Log:
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
Modified:
branches/10/ (props changed)
branches/10/include/asterisk/linkedlists.h
Propchange: branches/10/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.
Modified: branches/10/include/asterisk/linkedlists.h
URL: http://svnview.digium.com/svn/asterisk/branches/10/include/asterisk/linkedlists.h?view=diff&rev=376628&r1=376627&r2=376628
==============================================================================
--- branches/10/include/asterisk/linkedlists.h (original)
+++ branches/10/include/asterisk/linkedlists.h Tue Nov 27 11:35:54 2012
@@ -834,34 +834,38 @@
* \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
More information about the asterisk-commits
mailing list