Select one of the symbols to view example projects that use it.
 
Outline
#include <stdlib.h>
#include "libjaylink-internal.h"
list_prepend(struct list *, void *)
list_remove(struct list *, const void *)
list_find_custom(struct list *, list_compare_callback, const void *)
list_length(struct list *)
list_free(struct list *)
Files
loading...
SourceVuDevelopment ToolsOpenOCDsrc/jtag/drivers/libjaylink/libjaylink/list.c
 
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/* * This file is part of the libjaylink project. * * Copyright (C) 2014-2016 Marc Schink <jaylink-dev@marcschink.de> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. *//* ... */ #include <stdlib.h> #include "libjaylink-internal.h" /** * @file * * Singly-linked list functions. *//* ... */ /** @private */ JAYLINK_PRIV struct list *list_prepend(struct list *list, void *data) { struct list *item; item = malloc(sizeof(struct list)); if (!item) return NULL; item->data = data; item->next = list; return item; }{ ... } /** @private */ JAYLINK_PRIV struct list *list_remove(struct list *list, const void *data) { struct list *item; struct list *tmp; if (!list) return NULL; item = list; if (item->data == data) { tmp = item->next; free(item); return tmp; }if (item->data == data) { ... } while (item->next) { if (item->next->data == data) { tmp = item->next; item->next = item->next->next; free(tmp); break; }if (item->next->data == data) { ... } item = item->next; }while (item->next) { ... } return list; }{ ... } /** @private */ JAYLINK_PRIV struct list *list_find_custom(struct list *list, list_compare_callback callback, const void *user_data) { if (!callback) return NULL; while (list) { if (callback(list->data, user_data)) return list; list = list->next; }while (list) { ... } return NULL; }{ ... } /** @private */ JAYLINK_PRIV size_t list_length(struct list *list) { size_t length; for (length = 0; list; length++) list = list->next; return length; }{ ... } /** @private */ JAYLINK_PRIV void list_free(struct list *list) { struct list *tmp; while (list) { tmp = list; list = list->next; free(tmp); }while (list) { ... } }{ ... }
Details
Show:
from
Types: Columns:
Click anywhere in the source to view detailed information here...