-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist.h
58 lines (39 loc) · 1.11 KB
/
list.h
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef LIST_H
#define LIST_H
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
typedef enum {
list_success = 0,
list_null = -10,
list_not_found
} list_result;
typedef int (*fun_info_compare)(void *, void *);
typedef void (*fun_info_destroy)(void *);
typedef void (*fun_info_dump)(void *, FILE *);
typedef struct _node{
void *info;
struct _node *next;
} node;
typedef struct {
node *head;
size_t count;
pthread_mutex_t mux;
fun_info_compare info_compare;
fun_info_destroy info_destroy;
fun_info_dump info_dump;
} list;
//Thread Unsafe functions
list *list_create(fun_info_compare info_compare,
fun_info_destroy info_destroy,
fun_info_dump info_dump);
list_result list_insert_unsafe(list *l, void *info);
void *list_search_unsafe(list *l, void *info);
void* list_delete_unsafe(list *l, void *info);
// Thread Safe functions
list_result list_insert(list *l, void *info);
void *list_search(list *l, void *info);
int list_dump(list *l, FILE *f);
void *list_delete(list *l, void *info);
list_result list_destroy(list *l);
#endif