File: slist.h

package info (click to toggle)
libdebian-installer 0.127
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 680 kB
  • sloc: ansic: 5,007; makefile: 182
file content (121 lines) | stat: -rw-r--r-- 3,168 bytes parent folder | download | duplicates (10)
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
116
117
118
119
120
121
/*
 * slist.h
 *
 * Copyright (C) 2003 Bastian Blank <waldi@debian.org>
 *
 * 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/>.
 */

#ifndef DEBIAN_INSTALLER__SLIST_H
#define DEBIAN_INSTALLER__SLIST_H

#include <debian-installer/mem_chunk.h>

typedef struct di_slist di_slist;
typedef struct di_slist_node di_slist_node;

/**
 * @addtogroup di_slist
 * @{
 */
 
/**
 * @brief Single-linked list
 */
struct di_slist
{
  di_slist_node *head;                                  /**< head of list */
  di_slist_node *bottom;                                /**< bottom of list */
};

/**
 * @brief Node of a single-linked list
 */
struct di_slist_node
{
  di_slist_node *next;                                  /**< next node */
  void *data;                                           /**< data */
};

/**
 * Allocate a single-linked list
 *
 * @return a di_slist
 */
di_slist *di_slist_alloc (void);

/**
 * Destroy the contents of a single-linked list
 *
 * @warning never use this function with a list which makes use of the chunk allocator
 *
 * @param slist a di_slist
 */
void di_slist_destroy (di_slist *slist, di_destroy_notify destroy_func) __attribute__ ((nonnull(1)));

/**
 * Free a single-linked list
 *
 * @param slist a di_slist
 */
void di_slist_free (di_slist *slist);

/**
 * Append to a single-linked list
 *
 * @warning don't mix with di_slist_append_chunk
 *
 * @param slist a di_slist
 * @param data the data
 */
void di_slist_append (di_slist *slist, void *data) __attribute__ ((nonnull(1)));

/**
 * Append to a single-linked list
 *
 * @warning don't mix with di_slist_append
 *
 * @param slist a di_slist
 * @param data the data
 * @param mem_chunk a di_mem_chunk for allocation of new nodes
 *
 * @pre the di_mem_chunk must return chunks with at least the size of di_slist_node
 */
void di_slist_append_chunk (di_slist *slist, void *data, di_mem_chunk *mem_chunk) __attribute__ ((nonnull(1,3)));

/**
 * Prepend to a single-linked list
 *
 * @warning don't mix with di_slist_prepend_chunk
 *
 * @param slist a di_slist
 * @param data the data
 */
void di_slist_prepend (di_slist *slist, void *data) __attribute__ ((nonnull(1)));

/**
 * Prepend to a single-linked list
 *
 * @warning don't mix with di_slist_prepend
 *
 * @param slist a di_slist
 * @param data the data
 * @param mem_chunk a di_mem_chunk for allocation of new nodes
 *
 * @pre the di_mem_chunk must return chunks with at least the size of di_slist_node
 */
void di_slist_prepend_chunk (di_slist *slist, void *data, di_mem_chunk *mem_chunk) __attribute__ ((nonnull(1,3)));

/** @} */
#endif