qblist.h   qblist.h 
skipping to change at line 31 skipping to change at line 31
#ifndef QB_LIST_H_DEFINED #ifndef QB_LIST_H_DEFINED
#define QB_LIST_H_DEFINED #define QB_LIST_H_DEFINED
/* *INDENT-OFF* */ /* *INDENT-OFF* */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* *INDENT-ON* */ /* *INDENT-ON* */
#include <stdint.h> #include <stdint.h>
#include <qb/qbdefs.h>
/** /**
* @file qblist.h * @file qblist.h
* This is a kernel style list implementation. * This is a kernel style list implementation.
* *
* @author Steven Dake <sdake@redhat.com> * @author Steven Dake <sdake@redhat.com>
*/ */
struct qb_list_head { struct qb_list_head {
struct qb_list_head *next; struct qb_list_head *next;
skipping to change at line 61 skipping to change at line 62
#define QB_INIT_LIST_HEAD(ptr) do { \ #define QB_INIT_LIST_HEAD(ptr) do { \
(ptr)->next = (ptr); (ptr)->prev = (ptr); \ (ptr)->next = (ptr); (ptr)->prev = (ptr); \
} while (0) } while (0)
/** /**
* Initialize the list entry. * Initialize the list entry.
* *
* Points next and prev pointers to head. * Points next and prev pointers to head.
* @param head pointer to the list head * @param head pointer to the list head
*/ */
static void inline qb_list_init(struct qb_list_head *head) static inline void qb_list_init(struct qb_list_head *head)
{ {
head->next = head; head->next = head;
head->prev = head; head->prev = head;
} }
/** /**
* Add this element to the list. * Add this element to the list.
* *
* @param element the new element to insert. * @param element the new element to insert.
* @param head pointer to the list head * @param head pointer to the list head
*/ */
static void inline qb_list_add(struct qb_list_head *element, static inline void qb_list_add(struct qb_list_head *element,
struct qb_list_head *head) struct qb_list_head *head)
{ {
head->next->prev = element; head->next->prev = element;
element->next = head->next; element->next = head->next;
element->prev = head; element->prev = head;
head->next = element; head->next = element;
} }
/** /**
* Add to the list (but at the end of the list). * Add to the list (but at the end of the list).
* *
* @param element pointer to the element to add * @param element pointer to the element to add
* @param head pointer to the list head * @param head pointer to the list head
* @see qb_list_add() * @see qb_list_add()
*/ */
static void inline qb_list_add_tail(struct qb_list_head *element, static inline void qb_list_add_tail(struct qb_list_head *element,
struct qb_list_head *head) struct qb_list_head *head)
{ {
head->prev->next = element; head->prev->next = element;
element->next = head; element->next = head;
element->prev = head->prev; element->prev = head->prev;
head->prev = element; head->prev = element;
} }
/** /**
* Delete an entry from the list. * Delete an entry from the list.
* *
* @param _remove the list item to remove * @param _remove the list item to remove
*/ */
static void inline qb_list_del(struct qb_list_head *_remove) static inline void qb_list_del(struct qb_list_head *_remove)
{ {
_remove->next->prev = _remove->prev; _remove->next->prev = _remove->prev;
_remove->prev->next = _remove->next; _remove->prev->next = _remove->next;
} }
/** /**
* A quick test to see if the list is empty (pointing to it's self). * A quick test to see if the list is empty (pointing to it's self).
* @param head pointer to the list head * @param head pointer to the list head
* @return boolean true/false * @return boolean true/false
*/ */
skipping to change at line 198 skipping to change at line 199
* @param pos: the type to use as a loop counter. * @param pos: the type to use as a loop counter.
* @param head: the head for your list. * @param head: the head for your list.
* @param member: the name of the list_struct within the struct. * @param member: the name of the list_struct within the struct.
*/ */
#define qb_list_for_each_entry_reverse(pos, head, member) \ #define qb_list_for_each_entry_reverse(pos, head, member) \
for (pos = qb_list_entry((head)->prev, typeof(*pos), member); \ for (pos = qb_list_entry((head)->prev, typeof(*pos), member); \
&pos->member != (head); \ &pos->member != (head); \
pos = qb_list_entry(pos->member.prev, typeof(*pos), member)) pos = qb_list_entry(pos->member.prev, typeof(*pos), member))
/** /**
* Iterate over list of given type safe against removal of list entry
* @param pos: the type * to use as a loop cursor.
* @param n: another type * to use as temporary storage
* @param head: the head for your list.
* @param member: the name of the list_struct within the struct.
*/
#define qb_list_for_each_entry_safe(pos, n, head, member)
\
for (pos = qb_list_entry((head)->next, typeof(*pos), member),
\
n = qb_list_entry(pos->member.next, typeof(*pos), member);
\
&pos->member != (head);
\
pos = n, n = qb_list_entry(n->member.next, typeof(*n), member))
/**
* Iterate backwards over list safe against removal
* @param pos: the type * to use as a loop cursor.
* @param n: another type * to use as temporary storage
* @param head: the head for your list.
* @param member: the name of the list_struct within the struct.
*/
#define qb_list_for_each_entry_safe_reverse(pos, n, head, member)
\
for (pos = qb_list_entry((head)->prev, typeof(*pos), member),
\
n = qb_list_entry(pos->member.prev, typeof(*pos), member);
\
&pos->member != (head);
\
pos = n, n = qb_list_entry(n->member.prev, typeof(*n), member))
/**
* Count the number of items in the list. * Count the number of items in the list.
* @param head: the head for your list. * @param head: the head for your list.
* @return length of the list. * @return length of the list.
*/ */
static inline int32_t qb_list_length(struct qb_list_head *head) static inline int32_t qb_list_length(struct qb_list_head *head)
{ {
struct qb_list_head *item; struct qb_list_head *item;
int32_t length = 0; int32_t length = 0;
qb_list_for_each(item, head) qb_list_for_each(item, head)
 End of changes. 6 change blocks. 
4 lines changed or deleted 39 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/