Commit 3f0872b5 authored by Balázs Scheidler's avatar Balázs Scheidler Committed by Niels Möller
Browse files

* src/queue.h (struct object_queue_node): Made this structure public.

(FOR_OBJECT_QUEUE): Traverse an object_queue (Bazsi).
(FOR_OBJECT_QUEUE_REMOVE): Somewhat ugly macro to delete the
current node inside a for-loop.

Rev: src/queue.c:1.5
Rev: src/queue.h:1.4
parent a3184c85
......@@ -148,14 +148,6 @@ struct lsh_queue_node *lsh_queue_remove_tail(struct lsh_queue *q)
return n;
}
/* Object queue */
struct object_queue_node
{
struct lsh_queue_node header;
struct lsh_object *o;
};
static struct object_queue_node *
make_object_queue_node(struct lsh_object *o)
{
......
......@@ -70,6 +70,13 @@ struct lsh_queue_node *lsh_queue_remove_tail(struct lsh_queue *q);
#include "queue.h.x"
#undef GABA_DECLARE
/* Object queue */
struct object_queue_node
{
struct lsh_queue_node header;
struct lsh_object *o;
};
/* GABA:
(struct
(name object_queue)
......@@ -86,4 +93,17 @@ void object_queue_add_tail(struct object_queue *q, struct lsh_object *o);
struct lsh_object *object_queue_remove_head(struct object_queue *q);
struct lsh_object *object_queue_remove_tail(struct object_queue *q);
#define FOR_OBJECT_QUEUE(oq, n) \
struct lsh_queue_node *n##_this, *n##_next; \
struct lsh_object *n; \
for ( n##_this = (oq)->q.ht_links[LSH_QUEUE_HEAD]; \
( n = ((struct object_queue_node *) n##_this)->o, \
(n##_next = n##_this->np_links[LSH_QUEUE_NEXT])); \
n##_this = n##_next)
/* NOTE: You should probably use break or perhaps continue after removing the current node. */
/* FIXME: This name is rather ugly. */
#define FOR_OBJECT_QUEUE_REMOVE(n) (lsh_queue_remove(n##_this))
#endif /* LSH_QUEUE_H_INCLUDED */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment