1
/* vim:ts=8:sts=8:sw=4:noai:noexpandtab
3
* portable double-ended queue.
5
* Copyright (c) 2010-2011 Miru Limited.
7
* This library is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Lesser General Public
9
* License as published by the Free Software Foundation; either
10
* version 2.1 of the License, or (at your option) any later version.
12
* This library is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Lesser General Public License for more details.
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with this library; if not, write to the Free Software
19
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
#include <impl/framework.h>
30
const pgm_queue_t*const queue
33
pgm_return_val_if_fail (queue != NULL, TRUE);
35
return queue->head == NULL;
40
pgm_queue_push_head_link (
41
pgm_queue_t* restrict queue,
42
pgm_list_t* restrict head_link
45
pgm_return_if_fail (queue != NULL);
46
pgm_return_if_fail (head_link != NULL);
47
pgm_return_if_fail (head_link->prev == NULL);
48
pgm_return_if_fail (head_link->next == NULL);
50
head_link->next = queue->head;
52
queue->head->prev = head_link;
54
queue->tail = head_link;
55
queue->head = head_link;
61
pgm_queue_pop_tail_link (
65
pgm_return_val_if_fail (queue != NULL, NULL);
69
pgm_list_t *node = queue->tail;
71
queue->tail = node->prev;
74
queue->tail->next = NULL;
89
pgm_queue_peek_tail_link (
93
pgm_return_val_if_fail (queue != NULL, NULL);
101
pgm_queue_t* restrict queue,
102
pgm_list_t* restrict target_link
105
pgm_return_if_fail (queue != NULL);
106
pgm_return_if_fail (target_link != NULL);
108
if (target_link == queue->tail)
109
queue->tail = queue->tail->prev;
111
queue->head = pgm_list_remove_link (queue->head, target_link);