source: trunk/libtransmission/list.h @ 2746

Last change on this file since 2746 was 2746, checked in by charles, 14 years ago

make list less error-prone by changing the API s.t. we're guaranteed to update the list's pointer correctly.

File size: 1.8 KB
Line 
1/*
2 * This file Copyright (C) 2007 Charles Kerr <charles@rebelbase.com>
3 *
4 * This file is licensed by the GPL version 2.  Works owned by the
5 * Transmission project are granted a special exemption to clause 2(b)
6 * so that the bulk of its code can remain under the MIT license.
7 * This exemption does not extend to derived works not owned by
8 * the Transmission project.
9 */
10
11#ifndef TR_LIST_H
12#define TR_LIST_H
13
14typedef struct tr_list_s
15{
16    void              * data;
17    struct tr_list_s  * next;
18    struct tr_list_s  * prev;
19}
20tr_list_t;
21
22typedef int (*TrListCompareFunc)(const void * a, const void * b);
23typedef void (*TrListForeachFunc)(void *);
24
25void        tr_list_free           ( tr_list_t         ** list );
26
27void        tr_list_append         ( tr_list_t         ** list,
28                                     void               * data );
29
30void        tr_list_prepend        ( tr_list_t         ** list,
31                                     void               * data );
32
33void        tr_list_remove_data    ( tr_list_t         ** list,
34                                     const void         * data );
35
36void        tr_list_insert_sorted  ( tr_list_t         ** list,
37                                     void               * data,
38                                     TrListCompareFunc    compare_func );
39
40tr_list_t*  tr_list_find           ( tr_list_t          * list,
41                                     const void         * b,
42                                     TrListCompareFunc    compare_func );
43
44tr_list_t*  tr_list_find_data      ( tr_list_t          * list,
45                                     const void         * data );
46
47void        tr_list_foreach        ( tr_list_t          * list,
48                                     TrListForeachFunc    foreach_func );
49
50#endif /* TR_LIST_H */
51
Note: See TracBrowser for help on using the repository browser.