Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
list.h
Go to the documentation of this file.
1/*
2 * Copyright 2015-2018 Yubico AB
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef LIST_H
18#define LIST_H
19
20#include <stdbool.h>
21
22typedef void (*FreeItemFn)(void *);
23
24typedef bool (*CompareItemFn)(void *, void *);
25
26typedef void (*IteratorFn)(void *);
27
28typedef struct ListItem ListItem;
29
30struct ListItem {
31 void *data;
33};
34
42
43void list_create(List *list, int item_size, FreeItemFn free_item_fn);
44void list_destroy(List *list);
45
46bool list_prepend(List *list, void *item);
47bool list_append(List *list, void *item);
48
49ListItem *list_get(List *list, void *data, CompareItemFn compare_item_fn);
50void list_delete(List *list, ListItem *item);
51
52void list_iterate(List *list, IteratorFn iterator_fn);
53
54#endif
bool list_append(List *list, void *item)
Definition list.c:78
bool list_prepend(List *list, void *item)
Definition list.c:51
void list_delete(List *list, ListItem *item)
Definition list.c:117
bool(* CompareItemFn)(void *, void *)
Definition list.h:24
void(* IteratorFn)(void *)
Definition list.h:26
void list_iterate(List *list, IteratorFn iterator_fn)
Definition list.c:175
ListItem * list_get(List *list, void *data, CompareItemFn compare_item_fn)
Definition list.c:105
void list_create(List *list, int item_size, FreeItemFn free_item_fn)
Definition list.c:24
void list_destroy(List *list)
Definition list.c:33
void(* FreeItemFn)(void *)
Definition list.h:22
Definition list.h:35
int length
Definition list.h:36
ListItem * tail
Definition list.h:39
int item_size
Definition list.h:37
ListItem * head
Definition list.h:38
FreeItemFn free_item_fn
Definition list.h:40
void * data
Definition list.h:31
ListItem * next
Definition list.h:32