Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LIST: Additional macros for iteration over the list #5

Closed
wmdlr opened this issue May 25, 2011 · 3 comments
Closed

LIST: Additional macros for iteration over the list #5

wmdlr opened this issue May 25, 2011 · 3 comments

Comments

@wmdlr
Copy link
Contributor

wmdlr commented May 25, 2011

We propose to include in qblist.h the following macros:

/**

  • 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))
@asalkeld
Copy link
Contributor

Sure can. But beware debuggers really don't like these macros. They get really confused.
I am slowly removing the macros I once put in to the full code because of this.

It seems to be both the size of the macro and that there is iteration.

Why not post a patch to the mailing list?

-Angus

@wmdlr
Copy link
Contributor Author

wmdlr commented May 27, 2011

You mean to quarterback-devel@lists.fedorahosted.org ?

-Basil

@asalkeld
Copy link
Contributor

patch applied, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants