2 $Id: queue.c,v 1.1.2.1 2010-02-01 10:56:08 franklahm Exp $
3 Copyright (c) 2010 Frank Lahm <franklahm@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
18 * Netatalk utility functions: queue
23 #endif /* HAVE_CONFIG_H */
27 #include <atalk/queue.h>
29 static qnode_t *alloc_init_node(void *data)
32 if ((node = malloc(sizeof(qnode_t))) == NULL)
39 /********************************************************************************
41 *******************************************************************************/
47 if ((queue = alloc_init_node(NULL)) == NULL)
50 queue->prev = queue->next = queue;
54 qnode_t *enqueue(q_t *q, void *data)
58 if ((node = alloc_init_node(data)) == NULL)
75 if (q == NULL || q->next == q)
78 /* take first node from head */
82 node->next->prev = node->prev;
88 void queue_destroy(q_t *q, void (*callback)(void *))
92 while ((p = dequeue(q)) != NULL)