dlinklist.h revision 0d72f05cc87f42a8c2856c96501c64d69541be00
/*
some simple double linked list macros
Copyright (C) Andrew Tridgell 1998
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* To use these macros you must have a structure containing a next and
prev pointer */
#ifndef _DLINKLIST_H
#define _DLINKLIST_H
/* hook into the front of the list */
do { \
if (!(list)) { \
(list) = (p); \
} else { \
(list) = (p); \
}\
} while (0)
/* remove an element from a list - element doesn't have to be in list. */
#define DLIST_REMOVE(list, p) \
do { \
if ((p) == (list)) { \
} else { \
} \
} while (0)
/* promote an element to the top of the list */
#define DLIST_PROMOTE(list, p) \
do { \
DLIST_REMOVE(list, p); \
} while (0)
/* hook into the end of the list - needs a tmp pointer */
do { \
if (!(list)) { \
(list) = (p); \
} else { \
} \
} while (0)
/* insert 'p' after the given element 'el' in a list. If el is NULL then
this is the same as a DLIST_ADD() */
do { \
} else { \
}\
} while (0)
/* demote an element to the end of the list, needs a tmp pointer */
do { \
DLIST_REMOVE(list, p); \
} while (0)
/* concatenate two lists - putting all elements of the 2nd list at the
end of the first list */
do { \
if (!(list1)) { \
} else { \
if (list2) { \
} \
} \
} while (0)
/* insert all elements from list2 after the given element 'el' in the
* first list */
do { \
} else { \
} \
} while (0);
#define DLIST_FOR_EACH(p, list) \
#endif /* _DLINKLIST_H */