blob: 6644c22c87b0a55e7e937ed9b28b42cc05bdc83b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "libaco/aco.h"
struct aco_list {
aco_t *co;
int fd;
struct aco_list *next, *prev;
};
struct aco_list *aco_list_new () {
struct aco_list *head = malloc (sizeof (struct aco_list));
memset (head, 0, sizeof (struct aco_list));
head->next = head->prev = head;
return head;
}
struct aco_list *aco_list_add (struct aco_list *head, aco_t *co) {
struct aco_list *node = malloc (sizeof (struct aco_list));
node->co = co;
node->prev = head->prev;
node->next = head;
head->prev = node;
return node;
}
void aco_list_remove (struct aco_list *iter) {
if (iter->next == iter)
abort();
iter->prev->next = iter->next;
iter->next->prev = iter->prev;
}
|