2014-05-14 23:52:45 -04:00
|
|
|
/*
|
2014-05-16 08:22:25 -04:00
|
|
|
* r3_list.h
|
2014-06-27 01:24:40 -04:00
|
|
|
* Copyright (C) 2014 c9s <yoanlin93@gmail.com>
|
2014-05-14 23:52:45 -04:00
|
|
|
*
|
|
|
|
* Distributed under terms of the MIT license.
|
|
|
|
*/
|
|
|
|
|
2014-05-22 10:22:03 -04:00
|
|
|
#ifndef R3_LIST_H
|
|
|
|
#define R3_LIST_H
|
2014-05-14 23:52:45 -04:00
|
|
|
|
|
|
|
#include <pthread.h>
|
|
|
|
|
|
|
|
typedef struct _list_item {
|
|
|
|
void *value;
|
|
|
|
struct _list_item *prev;
|
|
|
|
struct _list_item *next;
|
|
|
|
} list_item;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int count;
|
|
|
|
list_item *head;
|
|
|
|
list_item *tail;
|
|
|
|
pthread_mutex_t mutex;
|
|
|
|
} list;
|
|
|
|
|
|
|
|
list *list_create();
|
|
|
|
void list_free(list *l);
|
|
|
|
|
|
|
|
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-22 10:22:03 -04:00
|
|
|
#endif /* !R3_LIST_H */
|