2
Based on gslist.c from glib-1.2.9 (LGPL).
4
Adaption to JACK, Copyright (C) 2002 Kai Vehmanen.
5
- replaced use of gtypes with normal ANSI C types
6
- glib's memery allocation routines replaced with
9
This program is free software; you can redistribute it and/or modify
10
it under the terms of the GNU Lesser General Public License as published by
11
the Free Software Foundation; either version 2.1 of the License, or
12
(at your option) any later version.
14
This program is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
GNU Lesser General Public License for more details.
19
You should have received a copy of the GNU Lesser General Public License
20
along with this program; if not, write to the Free Software
21
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
#ifndef __jack_jslist_h__
26
#define __jack_jslist_h__
30
typedef struct _JSList JSList;
32
typedef int (*JCompareFunc) (void* a,
42
jack_slist_alloc (void)
46
new_list = malloc(sizeof(JSList));
47
new_list->data = NULL;
48
new_list->next = NULL;
55
jack_slist_prepend (JSList *list,
60
new_list = malloc(sizeof(JSList));
61
new_list->data = data;
62
new_list->next = list;
67
#define jack_slist_next(slist) ((slist) ? (((JSList *)(slist))->next) : NULL)
70
jack_slist_last (JSList *list)
83
jack_slist_remove_link (JSList *list,
97
prev->next = tmp->next;
114
jack_slist_free (JSList *list)
118
JSList *next = list->next;
126
jack_slist_free_1 (JSList *list)
136
jack_slist_remove (JSList *list,
147
if (tmp->data == data)
150
prev->next = tmp->next;
155
jack_slist_free (tmp);
169
jack_slist_length (JSList *list)
185
jack_slist_find (JSList *list,
190
if (list->data == data)
200
jack_slist_copy (JSList *list)
202
JSList *new_list = NULL;
208
new_list = jack_slist_alloc ();
209
new_list->data = list->data;
214
last->next = jack_slist_alloc ();
216
last->data = list->data;
226
jack_slist_append (JSList *list,
232
new_list = jack_slist_alloc ();
233
new_list->data = data;
237
last = jack_slist_last (list);
238
last->next = new_list;
248
jack_slist_sort_merge (JSList *l1,
250
JCompareFunc compare_func)
258
if (compare_func(l1->data,l2->data) < 0)
269
l->next= l1 ? l1 : l2;
276
jack_slist_sort (JSList *list,
277
JCompareFunc compare_func)
289
while ((l2 = l2->next) != NULL)
291
if ((l2 = l2->next) == NULL)
298
return jack_slist_sort_merge (jack_slist_sort (list, compare_func),
299
jack_slist_sort (l2, compare_func),
303
#endif /* __jack_jslist_h__ */