Changeset 1ebc1a62 in mainline for uspace/app/sbi/src/list.c
- Timestamp:
- 2010-03-29T20:30:29Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a95310e
- Parents:
- 5da468e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/sbi/src/list.c
r5da468e r1ebc1a62 47 47 static bool_t list_node_present(list_t *list, list_node_t *node); 48 48 49 /** Initialize list. */ 49 /** Initialize list. 50 * 51 * @param list List to initialize. 52 */ 50 53 void list_init(list_t *list) 51 54 { … … 54 57 } 55 58 56 /** Append data to list. */ 59 /** Append data to list. 60 * 61 * Create a new list node and append it at the end of the list. 62 * 63 * @param list Linked list. 64 * @param data Data for the new node. 65 */ 57 66 void list_append(list_t *list, void *data) 58 67 { … … 63 72 } 64 73 65 /** Prepend data to list. */ 74 /** Prepend data to list. 75 * 76 * Create a new list node and prepend it at the beginning of the list. 77 * 78 * @param list Linked list. 79 * @param data Data for the new node. 80 */ 66 81 void list_prepend(list_t *list, void *data) 67 82 { … … 72 87 } 73 88 74 /** Remove data from list. */ 89 /** Remove data from list. 90 * 91 * Removes the given node from a list and destroys it. Any data the node might 92 * have is ignored. If asserts are on, we check wheter node is really present 93 * in the list the caller is requesting us to remove it from. 94 * 95 * @param list Linked list. 96 * @param node List node to remove. 97 */ 75 98 void list_remove(list_t *list, list_node_t *node) 76 99 { … … 82 105 } 83 106 84 /** Return first list node or NULL if list is empty. */ 107 /** Return first list node or NULL if list is empty. 108 * 109 * @param list Linked list. 110 * @return First node of the list or @c NULL if the list is empty. 111 */ 85 112 list_node_t *list_first(list_t *list) 86 113 { … … 93 120 } 94 121 95 /** Return last list node or NULL if list is empty. */ 122 /** Return last list node or NULL if list is empty. 123 * 124 * @param list Linked list. 125 * @return Last node of the list or @c NULL if the list is empty. 126 */ 96 127 list_node_t *list_last(list_t *list) 97 128 { … … 104 135 } 105 136 106 /** Return next list node or NULL if this was the last one. */ 137 /** Return next list node or NULL if this was the last one. 138 * 139 * @param list Linked list. 140 * @param node Node whose successor we are interested in. 141 * @return Following list node or @c NULL if @a node is last. 142 */ 107 143 list_node_t *list_next(list_t *list, list_node_t *node) 108 144 { … … 114 150 } 115 151 116 /** Return next list node or NULL if this was the last one. */ 152 /** Return previous list node or NULL if this was the last one. 153 * 154 * @param list Linked list. 155 * @param node Node whose predecessor we are interested in. 156 * @return Preceding list node or @c NULL if @a node is last. 157 */ 117 158 list_node_t *list_prev(list_t *list, list_node_t *node) 118 159 { … … 124 165 } 125 166 126 /** Return b_true if list is empty. */ 167 /** Return b_true if list is empty. 168 * 169 * @param list Linked list. 170 * @return @c b_true if list is empty, @c b_false otherwise. 171 */ 127 172 bool_t list_is_empty(list_t *list) 128 173 { … … 130 175 } 131 176 132 /** Change node data. */ 177 /** Change node data. 178 * 179 * Change the data associated with a node. 180 * 181 * @param node List node. 182 * @param data New data for node. 183 */ 133 184 void list_node_setdata(list_node_t *node, void *data) 134 185 { … … 136 187 } 137 188 138 /** Create new node. */ 189 /** Create new node. 190 * 191 * @param data Initial data for node. 192 * @return New list node. 193 */ 139 194 static list_node_t *list_node_new(void *data) 140 195 { … … 154 209 } 155 210 156 /** Delete node. */ 211 /** Delete node. 212 * 213 * @param node List node. Must not take part in any list. 214 */ 157 215 static void list_node_delete(list_node_t *node) 158 216 { … … 163 221 } 164 222 165 /** Insert node between two other nodes. */ 166 static void list_node_insert_between(list_node_t *n, list_node_t *a, list_node_t *b) 223 /** Insert node between two other nodes. 224 * 225 * Inserts @a n between neighboring nodes @a a and @a b. 226 * 227 * @param n Node to insert. 228 * @param a Node to precede @a n. 229 * @param b Node to follow @a n. 230 */ 231 static void list_node_insert_between(list_node_t *n, list_node_t *a, 232 list_node_t *b) 167 233 { 168 234 assert(n->prev == NULL); … … 177 243 } 178 244 179 /** Unlink node. */ 245 /** Unlink node. 246 * 247 * Unlink node from the list it is currently in. 248 * 249 * @param n Node to unlink from its current list. 250 */ 180 251 static void list_node_unlink(list_node_t *n) 181 252 { … … 197 268 } 198 269 199 /** Check whether @a node is in list @a list. */ 270 /** Check whether @a node is in list @a list. 271 * 272 * @param list Linked list. 273 * @param node Node. 274 * @return @c b_true if @a node is part of @a list, @c b_false otherwise. 275 */ 200 276 static bool_t list_node_present(list_t *list, list_node_t *node) 201 277 {
Note:
See TracChangeset
for help on using the changeset viewer.