r3/include/r3_list.h

36 lines
620 B
C
Raw Normal View History

2014-05-14 23:52:45 -04:00
/*
2014-05-16 08:22:25 -04:00
* r3_list.h
2014-05-14 23:52:45 -04:00
* Copyright (C) 2014 c9s <c9s@c9smba.local>
*
* Distributed under terms of the MIT license.
*/
#ifndef LIST_H
#define LIST_H
#include <pthread.h>
2014-05-19 06:54:13 -04:00
2014-05-14 23:52:45 -04:00
typedef struct _list_item {
2014-05-19 06:54:13 -04:00
void *value;
struct _list_item *prev;
struct _list_item *next;
2014-05-14 23:52:45 -04:00
} list_item;
2014-05-19 06:54:13 -04:00
2014-05-14 23:52:45 -04:00
typedef struct {
2014-05-19 06:54:13 -04:00
int count;
list_item *head;
list_item *tail;
pthread_mutex_t mutex;
2014-05-14 23:52:45 -04:00
} list;
2014-05-19 06:54:13 -04:00
2014-05-14 23:52:45 -04:00
list *list_create();
void list_free(list *l);
2014-05-19 06:54:13 -04:00
2014-05-14 23:52:45 -04:00
list_item *list_add_element(list *l, void *ptr);
int list_remove_element(list *l, void *ptr);
void list_each_element(list *l, int (*func)(list_item *));
2014-05-19 06:54:13 -04:00
2014-05-14 23:52:45 -04:00
#endif /* !LIST_H */